With the HAML code:
%form{:action => "activate_foobar", :method => :post, :controller => "foobar", :url => activate_foobar_foobar_index_path}
%input{:type => "submit", :value => "Activate"}
The submit button directs to
No route matches "/activate_foobar"
rather than to "/foobar/activate_foobar". It does not seem to understand the url parameter.
Details
On the index page of foobar, there is a form which I'm trying to post to foobar_controller's method activate_foobar. Foobar does not have a model, as there is no such object - it is only a specialised property of Widget. (Widget has a model, and a method .activate_foobar)
activate_foobar_foobar_index is defined in routes as:
resources :foobar, :only => [:index] do
collection do
post :activate_foobar
end
end
:confirmed with rake:routes to be:
activate_foobar_foobar_index POST /foobar/activate_foobar(.:format) {:action=>"activate_foobar", :controller=>"foobar"}
:as expected.
Furthermore, experimentation with a simple:
=link_to "Activate", activate_foobar_foobar_index_path, {:method => :post}
:routed successfully to /foobar/activate_foobar
Within the confines of using a form (and not using simple_form_for or other model based solutions), how do you correct the path "foobar/activate_foobar"?
Sources: I'm following http://guides.rubyonrails.org/routing.html "Adding more RESTful Actions" and http://www.w3schools.com/html/html_forms.asp to try to understand how to direct a form to the right method of the right controller.