Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Named routes generated without a method

#682

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.

Reported by diabolo · July 23rd, 2008 @ 01:54 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Jacques Crocker
    Jacques Crocker
    • 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.

    September 17th, 2008 @ 04:36 AM

  2. Marko Anastasov
    Marko Anastasov

    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.

    September 21st, 2008 @ 01:04 AM

  3. Pratik
    Pratik
    • State changed from new to invalid

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

    Thanks.

    December 21st, 2008 @ 01:44 PM