我在使用GeoKit進行郵政編碼搜索時遇到問題。一些錯誤導致整個應用程序崩潰。Ruby on Rails:GeoKit郵編搜索?
這是我有:
def zipcode
zipcode = params[:zipcode]
@bathrooms = Bathroom.geo_scope(:all, :origin=>[zipcode], :within=>10)
respond_to do |format|
format.json { render :json => @bathrooms }
#format.json { render :json => {:bathrooms => @bathrooms} }
format.js { render :nothing => true }
end
end
match '/bathrooms/zipcode', :controller => 'bathrooms', action =>"zipcode"
這是我收到的錯誤:
ArgumentError in BathroomsController#zipcode
wrong number of arguments (2 for 1)
Rails.root: /Users/chance 1/source/rails_projects/squat
Application Trace | Framework Trace | Full Trace
app/controllers/bathrooms_controller.rb:44:in `geo_scope'
app/controllers/bathrooms_controller.rb:44:in `zipcode'
Request
Parameters:
{"zipcode"=>"47130",
"format"=>"json"}
Show session dump
Show env dump
Response
Headers:
任何幫助表示讚賞。
您能否包含實際錯誤?你可以在Rails日誌(logs/development.log)中找到error/stacktrace –
ActionController :: RoutingError(沒有路由匹配[GET]「/bathrooms/zipcode.json」): –
Rendering /Library/Ruby/Gems/1.8 /modules/actionpackages/middleware/templates/rescues/routing_error.erb內救援/佈局(2.5ms) –