Rails 3.1.3 I have User model and Plan model User has the following association has_many :gives, :class_name => "Plan", :foreign_key => :give_id, :dependent => :destroy And a view generates <% @user.gives.each do |give| %> ... <li><%= link_to ''Delete'', {:controller => :plans, :action => :destroy, :id => give.id}, confirm: ''Are you sure?'', :class=>''btn btn-mini'' %></li> ... It is not Plan''s view, so I specified :controller as well. This Delete link somehow leads to Plan show action. It does not delete it as I want it to. Do you see any problem here ? Honestly, I don''t know what else to show you in order to find the problem. If more information is needed, please let me know. Thanks soichi -- 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 https://groups.google.com/groups/opt_out.
<%= link_to ''*Destroy*'', {:controller => :plans, :action => :destroy, :id => give.id}, confirm: ''Are you sure?'', :class=>''btn btn-mini'' %> see if this works On Thursday, 22 November 2012 09:24:26 UTC+5:30, Ruby-Forum.com User wrote:> > Rails 3.1.3 > > I have User model and Plan model > > User has the following association > > has_many :gives, :class_name => "Plan", :foreign_key => :give_id, > :dependent => :destroy > > And a view generates > > <% @user.gives.each do |give| %> > ... > <li><%= link_to ''Delete'', {:controller => :plans, :action => > :destroy, :id => give.id}, confirm: ''Are you sure?'', :class=>''btn > btn-mini'' %></li> > ... > > It is not Plan''s view, so I specified :controller as well. > > This Delete link somehow leads to Plan show action. It does not delete > it as I want it to. > > Do you see any problem here ? > > Honestly, I don''t know what else to show you in order to find the > problem. If more information is needed, please let me know. > > Thanks > > soichi > > -- > 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/W7wQjFtSixYJ. For more options, visit https://groups.google.com/groups/opt_out.
On 22 November 2012 03:53, Soichi Ishida <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Rails 3.1.3 > > I have User model and Plan model > > User has the following association > > has_many :gives, :class_name => "Plan", :foreign_key => :give_id, > :dependent => :destroy > > And a view generates > > <% @user.gives.each do |give| %> > ... > <li><%= link_to ''Delete'', {:controller => :plans, :action => > :destroy, :id => give.id}, confirm: ''Are you sure?'', :class=>''btn > btn-mini'' %></li> > ... > > It is not Plan''s view, so I specified :controller as well.I think the reason that it is not working is that you have not specified :method => delete. If you look at one of your delete links that works you will find that is specified. However there is no need to specify the controller or action, rails will work out what to do based on the type of the object, it is nothing to do with which view you are in, so link_to ''Delete'', give, confirm: ''Are you sure?'', :method => :delete should work. Colin> > This Delete link somehow leads to Plan show action. It does not delete > it as I want it to. > > Do you see any problem here ? > > Honestly, I don''t know what else to show you in order to find the > problem. If more information is needed, please let me know. > > Thanks > > soichi > > -- > 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 https://groups.google.com/groups/opt_out. > >-- 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 https://groups.google.com/groups/opt_out.
> link_to ''Delete'', give, confirm: ''Are you sure?'', :method => :delete > should work.Thanks! It worked! soichi -- 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 https://groups.google.com/groups/opt_out.
On 22 November 2012 08:22, Purushothaman Raju <purush97k-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <%= link_to ''Destroy'', {:controller => :plans, :action =>''Destroy'' is just the text that appears on the link. It will not affect the operation. Colin -- 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 https://groups.google.com/groups/opt_out.