I cannot force my link_to statement to send an HTTP put into my controller''s update method. It appears to be using get and therefore invoking the show method. Here is what my view looks like (I am using nested resources where item :has_many :costs): <%= link_to ''Recalculate'', item_cost_path(:recalc => 1), :method => :put, :action => :update %> When I click on the link in a browser: Unknown action No action responded to show. Actions: create, destroy, edit, index, new, and update I have tried many variations of link_to arguments and have been unable to make this work. Out of ideas, so I''m hoping you can help. Thanks! Mark -- 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.
What happens if you remove ":action => :update"? Shouldn''t be necessary cause put automatically calls the update method. -- 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.
Unfortunately that does not work. Same error, as if link_to is ignoring the :method argument and defaulting to get/show. On Apr 15, 4:22 am, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What happens if you remove ":action => :update"? Shouldn''t be necessary > cause put automatically calls the update method. > -- > Posted viahttp://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.
On 17 April 2010 07:16, MarkB <mark_balch-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Unfortunately that does not work. Same error, as if link_to is > ignoring the :method argument and defaulting to get/show.Have you checked the html generated by the link, and looked in the log to see if anything useful there? Colin> > > On Apr 15, 4:22 am, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> What happens if you remove ":action => :update"? Shouldn''t be necessary >> cause put automatically calls the update method. >> -- >> Posted viahttp://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. > >-- 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.
Colin Law wrote:> > Have you checked the html generated by the link, and looked in the log > to see if anything useful there? > > ColinYeah, what''s the output of <%= link_to ''Recalculate'', item_cost_path(:recalc => 1), :method => :put %>? -- 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.
On 17 April 2010 09:29, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> >> Have you checked the html generated by the link, and looked in the log >> to see if anything useful there? >> >> Colin > > Yeah, what''s the output of > <%= link_to ''Recalculate'', item_cost_path(:recalc => 1), :method > => :put %>?What have you got? 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
btw, found not much time ago, that you need to do :conditions => {:method => :put} instead of just :method => :put in routes.rb when define a route '' On Sat, Apr 17, 2010 at 4:01 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 17 April 2010 09:29, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Colin Law wrote: > >> > >> Have you checked the html generated by the link, and looked in the log > >> to see if anything useful there? > >> > >> Colin > > > > Yeah, what''s the output of > > <%= link_to ''Recalculate'', item_cost_path(:recalc => 1), :method > > => :put %>? > > What have you got? > > 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-/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.
The answer to seemingly broken rails behavior is usually "duh..I should have realized that!" My link_to syntax was fine. The HTTP put was successfully finding the correct controller method, but that method was performing a redirect that was failing (in a rather opaque way to me) because in this particular code path I did not initialize an instance variable (@item) that was the parameter to the redirect because I was bypassing a form_for...submit action that otherwise passes in the item.id: redirect_to edit_item_cost_path(@item, @cost) It appears that this RESTful helper fails with a not-too-insightful error when passed a bogus parameter. Thanks everyone who pitched in with suggestions and pointers. Mark On Apr 17, 2:01 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 17 April 2010 09:29, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Colin Law wrote: > > >> Have you checked the html generated by the link, and looked in the log > >> to see if anything useful there? > > >> Colin > > > Yeah, what''s the output of > > <%= link_to ''Recalculate'', item_cost_path(:recalc => 1), :method > > => :put %>? > > What have you got? > > 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@googlegroups.com. > For more options, visit this group athttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.