我预先在@bar的控制器中填充表单字段,当表单在视图中呈现时,它还会在视图中显示authenticity_token
。
def new
@content = params[:foo][:id]
@foo = Foo.find(@content)
@bar = Bar.new(title: @foo.title, body: @foo.body, foo_id: @foo.id)
end
观点代码:
<%= form_for @bar do |f| %>
<p>
<strong>Title: </strong>
<%= f.text_field :title, label: false, class: 'form-control' %>
</p>
<p>
<strong>Body: </strong>
<%= f.text_area :body, label: false, class: 'form-control' %>
</p>
<% end %>
如何删除在视图上呈现的authenticity_token?
答案 0 :(得分:1)
在表单中添加以下内容以删除身份验证令牌
:authenticity_token =&gt;假强>
<%= form_for @bar,:authenticity_token => false do |f| %>