Andrey Yasinishyn
Andrey Yasinishyn

Reputation: 1861

can't generate delete link in rails mailing view

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?

Upvotes: 1

Views: 246

Answers (1)

Demetris Constantinou
Demetris Constantinou

Reputation: 674

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.

Upvotes: 4

Related Questions