Rails 3-来自链接的Ajax POST单击 [英] Rails 3 - Ajax POSTS from a link click
问题描述
我正在尝试建立一个链接,该链接将执行ajax发布请求... rails 3方式.
I'm trying to make a link that will perform an ajax post request... the rails 3 way.
我设置了链接
<%= link_to "my link", things_path(:thing_type => 1, :user_id => person.id), :remote => true, :method => "post", :format => :js %>
该帖子可以工作并创建记录,但它抱怨缺少csrf令牌(位于我的meta标签中).
The post works and creates the record but it complains about missing csrf token (which is in my meta tags).
单击链接后,如何让rails.js发送csrf令牌?
How can I get rails.js to send the csrf token when the link is clicked?
推荐答案
据我所知,在Rails 3中有一个存在此bug的rails.js脚本.
As far as I remember there was a rails.js script that had this bug in Rails 3.
您可能应该更新您的jquery-rails并重新生成rails.js或仅用此
You should probably update your jquery-rails and regenerate rails.js or just replace rails.js with this one https://github.com/rails/jquery-ujs/blob/master/src/rails.js
这篇关于Rails 3-来自链接的Ajax POST单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!