This project is archived and is in readonly mode.

#682 ✓invalid
diabolo

Named routes generated without a method

Reported by diabolo | July 23rd, 2008 @ 01:54 PM | in 2.x

This output is from rake routes (not all the routes for cart_items are included)


home / {:method=>:get, :action=>"index", :controller=>"home"}

cart_items GET /cart_items {:action=>"index", :controller=>"cart_items"}

Notice how the first route does not have a method.

Here is the code from routes.rb


map.home '/', :controller => 'home', :action => 'index'

map.resources :cart_items

Since moving to Rails 2.1 this has been causing intermittent errors

ActionController::MethodNotAllowed Only get, head, post, put, and delete requests are allowed.

Googling suggests these errors might be due to Mongrel. But whether its Mongrel or Rails 2.1 or something else, it seems to me that fixing the underlying routes so that a specific GET method is generated by default would be a good thing to do.

Comments and changes to this ticket

  • Jacques Crocker

    Jacques Crocker September 17th, 2008 @ 04:36 AM

    • Tag changed from 2.1, routing to 2.1, routing

    Whenever I change my routes file, I also get the error "Only get, head, post, put, and delete requests are allowed.". Restarting the server fixes this.

    This is happening in development mode using the latest Mongrel (1.1.5) and Rails (2.1.1). Able to easily reproduce on multiple machines, though I cant reproduce it in unit tests.

  • Marko Anastasov

    Marko Anastasov September 21st, 2008 @ 01:04 AM

    I would get that error if I'd forget to write eg:

    map.resources :users, :member => { :settings => :get }

    for a named route

    map.settings 'settings', :controller => 'users', :action => 'settings'

    It is necessary to restart the server but I don't consider it a bug.

  • Pratik

    Pratik December 21st, 2008 @ 01:44 PM

    • State changed from “new” to “invalid”

    Please submit a failing test case if the issue is still there.

    Thanks.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Pages