Skip to content

Instantly share code, notes, and snippets.

Gems included by the bundle:
* actionmailer (3.2.0)
* actionpack (3.2.0)
* activemodel (3.2.0)
* activerecord (3.2.0)
* activeresource (3.2.0)
* activesupport (3.2.0)
* acts_as_list (0.1.4)
* ansi (1.4.1)
* arel (3.0.0)
def self.search(params)
conditions = []
matches = []
if params[:first_name].present?
conditions << "first_name = ?"
matches << params[:first_name]
end
if params[:last_name].present?
conditions << "last_name = ?"
matches << params[:last_name]
class String
def char_replace(position, char)
self[0...position] + char + self[position + 1 .. -1]
end
end
def self.retrieve_rate_from_redis(location_code, ratecode, cartype, pickup_date, pickup_time)
base_key = "rate:#{location_code}:#{ratecode}:#{cartype}"
default_rate_key = base_key + ":default"
rate_key = base_key + ":" + pickup_date.to_s
value = $redis.hgetall (rate_key + ":#{pickup_time[0,2]}") #use TOD rate if tod rate exists
value = $redis.hgetall rate_key if value.blank? #use regular rate if TOD rate not found
value = $redis.hgetall default_rate_key if value.blank? #use default rate if regular rate not found
value
end
def self.qualifying_cartypes(location, cartypes)
result = []
supported_cartypes = location.supported_car_types
cartypes.split(":").each do |cartype|
name_match = cartype[0,4].gsub('*','_').ljust(4,'_')
if cartype[4,1] == '*'
minimum_cartype = CarType.where("name ilike ?", "#{name_match}%").order(:position).first
supported_cartypes.each {|i| result << i.name if i.position.to_i >= minimum_cartype.position}
elsif cartype == '*'
test = -> alert 'hi'
$ ->
test()
#this works
$ ->
mydata = [{pickup: '03/01/2011'}]
for data,i in mydata
$('#rates_grid').jqGrid 'addRowData', i+1, data
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
render :template => 'rates/refresh_location.coffee
DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:coffee] instead.
Started GET "/api/cartypes?location=PHX4" for 127.0.0.1 at 2012-02-28 17:48:25 -0500
Processing by ApiController#cartypes as HTML
Parameters: {"location"=>"PHX4"}
(0.6ms) SELECT car_types.name FROM "car_types" WHERE (locations.code = 'PHX4')
PG::Error: ERROR: missing FROM-clause entry for table "locations"
LINE 1: SELECT car_types.name FROM "car_types" WHERE (locations.cod...
^
: SELECT car_types.name FROM "car_types" WHERE (locations.code = 'PHX4')
Completed 500 Internal Server Error in 14ms