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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 ...... On Mon, Apr 26, 2010 at 12:10 AM, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
... or at least link_to "Ne pluys participer", participant_path(current_user), :method => :delete ...... On Sun, Apr 25, 2010 at 11:10 PM, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks guys -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi, I am trying to generate a link to delete a relationship, so I''ve done the code bellow. THis is the full code, the part for deleting the relationship is at the bottom of the code. I am using a restful controller <% unless item.user_participe?(current_user) %> <%form_for Participant.new do |f| %> <%= f.hidden_field :defi_id, :value => item.id%> <%= f.submit "Participer!", :disabled => !current_user %> <%link_to("Créez un compte pour participer", register_path) unless current_user %> <% end %> <%else%> <i>Vous participez à ce défi</i> <%= link_to "Ne plus participer", participant_path(item.participants.find_by_user_id(current_user.id)) , :method => :delete, :confirm => "Etes vous sur de ne plus vouloir participer?" %> <%end%> This is the error message: participant_url failed to generate from {:action=>"show", :controller=>"participants", :id=>#<Participant user_id: 1, defi_id: 1, is_valide: "false", fin_defi: "2010-04-24 00:00:00", created_at: "2010-04-25 15:15:35", updated_at: "2010-04-25 15:15:35">}, expected: {:action=>"show", :controller=>"participants"}, diff: {:id=>#<Participant user_id: 1, defi_id: 1, is_valide: "false", fin_defi: "2010-04-24 00:00:00", created_at: "2010-04-25 15:15:35", updated_at: "2010-04-25 15:15:35">} Greg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The reason it is failing is because it is performing a GET request. Wrap the "delete relationship" in a form( with :method => :delete) and it should work -- Punit Greg Ma wrote:> Hi, > I am trying to generate a link to delete a relationship, so I''ve done > the code bellow. THis is the full code, the part for deleting the > relationship is at the bottom of the code. I am using a restful > controller > > <% unless item.user_participe?(current_user) %> > <%form_for Participant.new do |f| %> > <%= f.hidden_field :defi_id, :value => item.id%> > <%= f.submit "Participer!", :disabled => !current_user %> <%> link_to("Créez un compte pour participer", register_path) unless > current_user %> > <% end %> > > <%else%> > <i>Vous participez à ce défi</i> > <%= link_to "Ne plus participer", > participant_path(item.participants.find_by_user_id(current_user.id)) , > :method => :delete, :confirm => "Etes vous sur de ne plus vouloir > participer?" %> > <%end%> > > This is the error message: > participant_url failed to generate from {:action=>"show", > :controller=>"participants", :id=>#<Participant user_id: 1, defi_id: 1, > is_valide: "false", fin_defi: "2010-04-24 00:00:00", created_at: > "2010-04-25 15:15:35", updated_at: "2010-04-25 15:15:35">}, expected: > {:action=>"show", :controller=>"participants"}, diff: > {:id=>#<Participant user_id: 1, defi_id: 1, is_valide: "false", > fin_defi: "2010-04-24 00:00:00", created_at: "2010-04-25 15:15:35", > updated_at: "2010-04-25 15:15:35">} > > > Greg-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.