无法在Rails邮件视图中生成删除链接 [英] can't generate delete link in rails mailing view
问题描述
在我看来,我有2个链接:
一个用于编辑,效果很好,一个用于破坏动作。
In my view I have 2 links: one for edit, that works great, and one for destroy action.
方法如下:> p>
metod looks like:
def create_ticket(ticket)
@ticket = ticket
@edit = edit_ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password)
@destroy = ticket_url(@ticket, :host => "localhost:3000", :guest_password => @ticket.guest_password)
mail(:to => @ticket.email, :subject => @ticket.subject)
end
在视图模板中:
<%= link_to "Edit Ticket", @edit %>
<%= link_to "Delete Ticket", @destroy, :method => :delete %>
最后一个只是获取路径而不是破坏物品。
the last one simply getting path instead of destroying item.
如何解决这个问题?
推荐答案
我认为原因不起作用是因为:method =>:delete使用javascript处理,并且从电子邮件中单击链接,不会触发javascript。我本可以尝试解决此问题的方法是将一个参数传递给url之类的 delete = true,然后在控制器中对其进行处理。
The reason is not working, i think, is because the :method => :delete is handled with javascript, and since the link is clicked from the email, javascript is not triggered. The way I would have try to solve this is by passing a parameter to the url like "delete=true" and handle it with that in the controller.
这篇关于无法在Rails邮件视图中生成删除链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!