2013-06-25 42 views
0

使用的form_for我想发送电子邮件给用户里面的一种形式:如何的ActionMailer

我尝试以下

booking_confirmation.html.erb

<%= form_for(@event, :html => { :method => :put }) do |f| %> 
<%= f.hidden_field(:customer_id, :value => nil) %> 
<%= f.submit "Cancel", class: "btn btn-large btn-primary", :confirm => 'Are you sure?' %> 
<% end %> 

但后来我不得不在UserMailerHelper中设置protect_against_forgeryfalse,这会打乱我的登录操作...

是否没有更简单的方法来j请用我的event_url发送一个PUT请求,其中一个参数为:customer_id

谢谢你的帮助!

我也试过以下。它不起作用,有没有人看到为什么,并可以帮助我通过它?

<%= link_to "Cancel", url_for(controller: 'events', action: 'update', only_path: false, :customer_id => "0"), :confirm => 'Are you sure?' %> 

回答

0

你为什么要使用form_for的形式,只是用带有参数的链接的形式替换它。

<%= link_to "Cancel", url_for(:action => event_url, :customer_id => @event.customer_id), :class => "btn btn-large btn-primary", :confirm => 'Are you sure?' %> 
+0

谢谢您的回应!我试过,但后来我收到以下错误:'没有路由匹配{:行动=>“显示”,:控制器=>“事件”}'。我认为有必要指定的行动,但我不知道如何route.rb配置如何 – lgerard

+0

? –