1

我有一个控制器,其中有一个自定义操作(不是 RESTful 集的一部分)来创建关联对象。

没有添加到表单中,我认为这authenticity_token是因为该操作不是 RESTful 集的一部分?

authenticity_token当它没有自动添加时,我将如何添加?

4

1 回答 1

4

添加

<%= hidden_field_tag "authenticity_token", form_authenticity_token %>

到你的表格。

你可以为此做一个助手:

def authenticity_token_tag
  hidden_field_tag "authenticity_token", form_authenticity_token 
end

然后在你的表格中你可以说

<%= authenticity_token_tag %>
于 2014-05-29T11:46:45.783 回答