我正在使用这个 jquery 帖子
navigator.geolocation.getCurrentPosition(function(position){
$.post('/marketplace',{latitude: position.coords.latitude, longitude: position.coords.longitude})
});
路线:
post '/marketplace' => 'pages#marketplace'
在控制台中的控制器Rails.logger.debug('Jquery.POST' + params.inspect)
打印中
Started POST "/marketplace" for 127.0.0.1 at 2011-05-20 13:23:16 +0300
Processing by PagesController#marketplace as
Parameters: {"latitude"=>"44.508851", "longitude"=>"33.600509"}
Jquery.POST{"latitude"=>"44.508851", "longitude"=>"33.600509", "controller"=>"pages", "action"=>"marketplace"}
萤火虫还说纬度 44.508851 和经度 33.600509 已成功发送。但在视图中我没有我的帖子数据,= params.inspect
{"action"=>"marketplace", "controller"=>"pages"}
如何在控制器中访问我的 jquery 发布数据?
*更新
@lat = request.params[:latitude]
@long = request.params[:longitude]
视图中都为零:(