Skip to content

Instantly share code, notes, and snippets.

@jmoody
Created April 29, 2011 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoody/948820 to your computer and use it in GitHub Desktop.
Save jmoody/948820 to your computer and use it in GitHub Desktop.
def create
params.each do |key,value|
logger.warn "Param #{key}: #{value}"
end
url_args = { :latitude => params["longitude"], :longitude => params["longitude"] }
logger.debug "url_args = #{url_args}"
@count_threshold = CountThreshold.new(url_args)
@count_threshold.save
#ActiveRecord::Base.include_root_in_json = false
respond_with(@count_threshold) do |format|
format.html { render :json => @count_threshold }
format.json { render :json => @count_threshold }
end
end
@jmoody
Copy link
Author

jmoody commented Apr 29, 2011

Param longitude: -2.4876
Param latitude: 194.5432
Param action: create
Param controller: count_thresholds
url_args = {:latitude=>"-2.4876", :longitude=>"-2.4876"}

@jmoody
Copy link
Author

jmoody commented Apr 29, 2011

When sent JSON;

Parameters: {"longitude"=>194.5432, "latitude"=>194.5432}
Param longitude: 194.5432
Param latitude: 194.5432
Param action: create
Param controller: count_thresholds
Param format: json
url_args = {:latitude=>194.5432, :longitude=>194.5432}

@jmoody
Copy link
Author

jmoody commented Apr 29, 2011

class CountThreshold < ActiveRecord::Base
attr_accessor :target_accuracy_percent, :min_bikes_to_count, :min_survey_time_seconds
attr_accessor :latitude, :longitude

before_save :fill_in_thresholds

def fill_in_thresholds
@target_accuracy_percent = 34
@min_bikes_to_count = 21
@min_survey_time_seconds = 780
end

@michaelkirk
Copy link

def fill_in_thresholds
target_accuracy_percent = 34
min_bikes_to_count = 21
min_survey_time_seconds = 780
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment