【发布时间】:2011-12-28 06:53:32
【问题描述】:
我有一个 Rails 3.1 应用程序,我可以在其中创建邮件群发。我有一个我所有的爆炸列表,其中包含一个邮件链接,用于邮寄特定的爆炸(使用 ajax)。我的爆炸控制器中有一个我想使用的自定义操作。当我单击它想要调用 show.js.coffee 而不是 mail.js.coffee 的链接时。我如何强制它使用我创建的动作。当我把所有东西都放在我的控制器的 show 动作和 show.js.coffee 但不是 mail 动作和 mail.js.coffee 等时,一切正常。
这是我的爆炸部分
<td><% if can? :create, Blast%><%= link_to "Mail",blast,:action => :mail :confirm => "Are you sure?",:remote => true%><%end%></td>
这是控制器中的方法
def mail
@customers = Customer.all
@mailcustomers = Customer.where(:opted_out => false)
@blast = Blast.find(params[:id])
end
这是在我的 mail.js.coffee 文件中
<% @mailcustomers.each do |f|%>
<% BlastMailer.mail_blast(f,@blast).deliver %>
<%end%>
在 routes.rb 中
resources :blasts do
collection { post :mail }
end
【问题讨论】:
标签: jquery ruby-on-rails-3.1 coffeescript