2

我正在尝试为用户创建一封邮件,其中包含一个简单的 html 表单。为此,我按照http://edgeguides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration教程中的建议使用 Rails 3 中的 ActionMailer

我无法在邮件程序 erb 文件中使用诸如 form_tag 之类的 ActionView 助手。如何在 erb 文件中访问它们。

我的 user.html.erb 文件有这样的代码:

<%= form_tag(:controller => "application", :action => "parent_select", :method=>"put") do %>
  Want To Attend
  <%= check_box_tag(:yes, '1', request.priority != 0) %>

<% end %>

我收到此错误:

undefined method `protect_against_forgery?' for #<#<Class:0xa0874c4>:0xa085a70>
4

1 回答 1

0

将表单放入电子邮件中不是一个好主意,请参阅:

http://www.campaignmonitor.com/blog/post/2435/how-forms-perform-in-html-emai/

但是您在这里看到的是在没有 csrf_meta_tag(表单令牌和身份验证)的情况下发送的表单。您可以为此操作关闭防伪保护,也可以手动将这些字段添加到您的表单中。

于 2011-06-13T19:10:09.147 回答