Link_to delete action

Hi, I'm having problem with a link_to delete action. I don't understant what i'm doing is wrong.

Here is my code:   <% participant = item.participants(:user_id => current_user.id).first %>   <%= link_to "Ne plus participer", participant , :method => :delete, :confirm => "Etes vous sur de ne plus vouloir participer?" %>

Greg

Hi Greg,

You might want to put your variable assignment (participant) in your controller instead of your view.

In your link_to, ‘participant’ has no meaning. Do you have RESTful routing setup? Perhaps you meant to write:

<%= link_to “Ne pluys participer”, participant_path(@participant), :method => :delete …

… or at least

link_to “Ne pluys participer”, participant_path(current_user), :method => :delete …

Thanks guys

Actually I was wrong, I am thinking the thing the wrong way.

I have a model Defi which as many Participant. I would like to create a link_to to add a Participant to a Defi. How do I do this? Is it in the Defi controller or the Participant controller?

Greg