繁体   English   中英

如何在 rails 3 的邮件程序中使用表单助手?

[英]How do I use form helpers in the mailer in rails 3?

我正在尝试向用户创建一封邮件,其中包含一个简单的 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>

将您的表单放入 email 并不是一个好主意,请参阅:

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM