Ruby on Rails Thursday, March 31, 2011

Hello there,
I'm doing a form and I want to send this form with method="post". Head
of form looks so:

<%= form_tag({ :controller => 'admin', :action => 'menu_add' }, {
:method => 'post' }) do %>

And in controller I have this:

def menu_add
menu_new = Menu.new(...)
...
end

And with I am fighting - I'm not using type of route get
'admin/menu_add' - I'm sending a form by method post -- but I am still
getting the route error "Unknown action - The action 'menu_add' could
not be found for AdminController" -- how it is possible, if I'm not
using route 'admin/menu_add' by get, but by post?

And one question yet - exist some effective way, how to work with
routes? If i want to add some new action, I must to add to file
'routes.rb' line as:

get 'admin/menu_add'
post 'admin/menu_add'

It's a bit boring to add every new action so manually... is some better
way, how to do?

Thanks a lot, Manny.

--
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@googlegroups.com.
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.

No comments:

Post a Comment