Created
April 29, 2011 19:06
-
-
Save jmoody/948820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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}
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
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
Param longitude: -2.4876
Param latitude: 194.5432
Param action: create
Param controller: count_thresholds
url_args = {:latitude=>"-2.4876", :longitude=>"-2.4876"}