问题
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