【发布时间】:2011-03-22 19:51:15
【问题描述】:
我在模板 new.html.erb 中有一个 form_for,我在其中正常保存到数据库,然后发送一封成功的电子邮件。我希望邮件程序发送与正文相同的 new.html.erb 并传递模型,以便完全填充表单。我收到以下错误:
undefined method `protect_against_forgery?' for #<#<Class:0x000000049d7110>:0x000000049d4690>
紧跟在 form_for 标记之后(因为我认为它正在注入 auth 标记标记)。有没有办法可以规避这个问题,以便我可以在邮件程序中重复使用模板?
这是邮件程序代码的样子
class MaintenanceMailer < ActionMailer::Base
helper :application
def request_email(maintenance)
mail :to => maintenance.community.email, :subject => "Maintenance" do |format|
format.html { render :layout => 'default', :template => 'maintenance/new' }
end
end
end
【问题讨论】:
标签: ruby-on-rails-3 actionmailer actionview form-helpers