I got this error when I have to upgrade one old project from rails 1.2.5 to rails 2.1 (the problem is not in rails)
ActionController::MethodNotAllowed Only get, head, post, put, and delete requests are allowed.
The exception:
ActionController::MethodNotAllowed (Only get, head, post, put, and delete requests are allowed.): /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize'
I got this error only when I access URL’s with param like
http://127.0.0.1:3000/dod/images/show_big_image/1639
I found that the problem was in the :id because without the :id the method was called correctly
This means that there is something with the routes.
Not working routes.rb: ….
map.connect '', :controller => 'auth' # Install the default route as the lowest priority. map.connect ':controller/:action/:id' map.connect ':controller/:action/:sort_key/:sort_order'
it will work if you swap the last two lines….
map.connect '', :controller => 'auth' # Install the default route as the lowest priority. map.connect ':controller/:action/:sort_key/:sort_order' map.connect ':controller/:action/:id'
It seems that it does reading the comments in the routes.rb is usefull. There is written:
# Install the default route as the lowest priority. This error also occurs if you haven't restart your webserver. I know that there is no need to restart it but its true, try restarting and check.
J October, 2008 at 1:04 pm
thank you for post. it seems that position of routes must be from the most specified to less specified, in other words:
/:this/should/precede
/:this/another/route/:id