我在導軌mvc上使用紅寶石,我試圖使用ajax調用來發送一些數據回服務器端。我對如何在mvc中發出和處理ajax請求感到困惑。ajax調用導致內部服務器錯誤500導軌控制器
----------------在我的JavaScript文件------------------
} );
我使用的respond_to塊捕獲在我的控制器這個請求:
----------------在我家控制器------- -----------
respond_to do |format|
format.js {
render 'users/locations'
}
format.html {}
end
---------------- route.rb ------------- -----------
post 'users/locations'
get 'users/locations'
match "/locations", to: "users#locations"
我想這種方式提取數據:
----------------在我的位置action ------------------
dasdasdd // used as a breakpoint to test whether this part was executed. it wasn't.
current_user.update_attribute :Latitude, params[:lat]
current_user.update_attribute :Longitude, params[:lng]
隨着調試firefox控制檯,我看到內部服務器錯誤500.這可能解釋爲什麼位置操作從未執行。但爲什麼會出現錯誤500?任何人都可以照亮我可能會怎樣錯的?
你可以找到大量的信息在'應用程序/ development.log '以及關於異常的'500'錯誤的響應主體。我們只是猜測你的問題是什麼,而不知道* Exception拋出的是什麼。 – deefour