我想創建一個郵件給用戶,其中包括一個簡單的HTML表單。爲此,我使用Rails 3中的ActionMailer,如教程中所建議的http://edgeguides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration如何在導軌3的郵件程序中使用表單助手?
我無法在郵件erb文件中使用ActionView助手,如form_tag。我如何在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>
無法工作的唯一幫手是form_tag,因爲它需要protect_from_forgery?它僅由ActionController實現,並且在ActionMailer的視圖中不可用。所以我可以通過手動生成form_tag helper的html來解決它。其餘的助手(check_box_tag,submit_tag)工作正常。 – 2011-06-15 06:12:06