【发布时间】:2011-06-13 00:19:13
【问题描述】:
我正在努力解决我的 AJAX 调用的安全问题。我有一个删除笔记的 jQuery post call。根据我的阅读,我似乎需要使用protect_from_forgery 来确保帖子来自有效用户。
这是我目前所拥有的
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
...
index.html
$.post('../delete_note',{id:$('#note_id').val()}, function(data) {
});
note_controller.rb
def delete_note
y params
render :text => "success"
end
目前,发布请求由 Rails 运行,即使我没有发送任何安全令牌。我需要做些什么来确保通话安全?
我正在使用 Rails 3.0.1 和 devise 进行用户管理。
【问题讨论】:
标签: ruby-on-rails ajax security csrf