Clearly Defined Route Not Found

17 views
Skip to first unread message

Neil Chaudhuri

unread,
May 15, 2012, 6:53:58 PM5/15/12
to rubyonra...@googlegroups.com
In routes.rb I have this:

resources :presentations do
post "save_stuff", :on => :member
end

In PresentationsController I have this:

def save_stuff
...
end

And in my form I have this:

<%= form_for @presentation, :url => {:action => "save_stuff"}, :html =>
{:id => "presentationForm", :method => :post} do |f| %>

Yet when an attempt is made to render the above form I get this:

!! Unexpected error while processing request: No route matches
{:action=>"save_stuff", :controller=>"presentations"}

I have been struggling with this for hours, so I could use some help.

Thanks.

--
Posted via http://www.ruby-forum.com/.

Walter Lee Davis

unread,
May 15, 2012, 8:56:48 PM5/15/12
to rubyonra...@googlegroups.com
What do you see when you type rake routes in Terminal?

Walter


David Hill

unread,
May 15, 2012, 9:01:01 PM5/15/12
to rubyonra...@googlegroups.com
I haven't seen the :on syntax before.  Have you tried it like this?

resources :presentations do
   member do
      post "save_stuff"
   end
end



--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Frederick Cheung

unread,
May 16, 2012, 5:06:42 AM5/16/12
to Ruby on Rails: Talk
You've said that save_stuff is a member thing, so rails needs to know
which presentation you want to save stuff on. The :url option
completely overrides the route that would normally be generated (to
the update action) so you need to specify the id as well. You could
also use the named route - :url =>
save_stuff_presentation_path(@presentation)

Fred

Robert Reiz

unread,
Jun 21, 2013, 11:28:19 AM6/21/13
to rubyonra...@googlegroups.com
I have the same problem. 

Any ideas ? 
Reply all
Reply to author
Forward
0 new messages