Ruby on rails michael hartl教程第12章中使用ajax创建的工作流程按钮

Ruby on rails michael hartl教程第12章中使用ajax创建的工作流程按钮,ruby-on-rails,ajax,Ruby On Rails,Ajax,我正在研究ajax,并使用教程编写了以下代码: 使用Ajax跟踪用户的表单 <%= form_for(current_user.active_relationships.build, remote: true) do |f| %> <div><%= hidden_field_tag :followed_id, @user.id %></div> <%= f.submit "Follow", class: "btn btn-primary" %

我正在研究ajax,并使用教程编写了以下代码:

使用Ajax跟踪用户的表单

<%= form_for(current_user.active_relationships.build, remote: true) do |f| %>
<div><%= hidden_field_tag :followed_id, @user.id %></div>
<%= f.submit "Follow", class: "btn btn-primary" %>
<% end %>

使用Ajax取消跟踪用户的表单:

<%= form_for(current_user.active_relationships.find_by(followed_id: @user.id),
html: { method: :delete },
remote: true) do |f| %>
<%= f.submit "Unfollow", class: "btn" %>
<% end %>

config/application.rb

require File.expand_path('../boot', __FILE__)
... module SampleApp
class Application < Rails::Application
.
.
.
# Include the authenticity token in remote forms.
config.action_view.embed_authenticity_token_in_remote_forms = true
end
end
需要文件。展开路径('../boot',文件)
... 模块示例应用程序
类应用程序
但我得到了这个错误

ActionController::关系中的InvalidAuthenticationToken控制器#创建

请帮我解决这个问题

编辑:

我已经用这个检查过了

一,
caches\u页面:索引,:显示
在筛选器之前跳过\u:验证\u真实性\u令牌,:only=>[:index,:show]

2
这已经在我的布局中

3
使用::null\u会话保护\u免受伪造


但是这个错误仍然显示了可能的重复,或者我在@pavan之前检查了这些链接,但无法得到任何解决方案尝试在
skip\u-before\u-filter
中添加
:create
,现在它的给出错误
未定义的方法
缓存页面`