can't generate delete link in rails mailing view

痴心易碎 提交于 2019-12-24 13:23:29

问题


In my view I have 2 links: one for edit, that works great, and one for destroy action.

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

in view template:

<%= link_to "Edit Ticket", @edit %>
<%= link_to "Delete Ticket", @destroy, :method => :delete %>

the last one simply getting path instead of destroying item.

How to solve this?


回答1:


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.



来源:https://stackoverflow.com/questions/17123905/cant-generate-delete-link-in-rails-mailing-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!