Jun 17

Rails Error: ActionController::MethodNotAllowed

Category: Programming

I ran into this error in Rails today:
Only get, head, post, put, and delete requests are allowed.With the trace ending on this line:
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path'

Turns out I had two versions of rails installed and my application was looking for the wrong version. I had to go into my application folder and edit config/environment.rb and changed line 8 from:
RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
to:
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

Just in case, you know, you run into a similar problem.



del.icio.us:Rails Error: ActionController::MethodNotAllowed .digg:Rails Error: ActionController::MethodNotAllowed .spurl:Rails Error: ActionController::MethodNotAllowed .newsvine:Rails Error: ActionController::MethodNotAllowed .furl:Rails Error: ActionController::MethodNotAllowed .reddit:Rails Error: ActionController::MethodNotAllowed .Y!:Rails Error: ActionController::MethodNotAllowed

9 Comments so far

  1. Thomas Reynolds June 17th, 2008 3:30 pm

    You mean you had two versions of Rails, not Ruby… right?

  2. Benco June 19th, 2008 7:30 am

    Yes. I blame this typo on alliteration.

  3. Pablo Formoso June 26th, 2008 5:20 am

    Just update your mongrel version to 1.15 and the problem is fixed.

    gem update mongrel

  4. Eric Berry June 29th, 2008 11:05 am

    I already had mongrel 1.1.5 installed and I still get this issue. As far as having to revert the application from a 2.1 Rails app to a 2.0.2 Rails app, that only tells us that it’s an issue with 2.1 which needs fixing.

    Anybody else have this issue?

  5. Brandan Lennox July 3rd, 2008 11:48 am

    I was having this issue as well. I had this route in routes.rb:

    map.connect ‘/:page’, :controller => ‘theme’, :action => ‘view’, :defaults => { :page => ‘index’ }

    In script/console, running rs.recognize_path on any proper route would work, and browsing to http://localhost:3000/ would render as well, but browsing to http://localhost:3000/anything-else would cause that MethodNotAllowed error.

    Updating Mongrel fixed it for me, so I can’t really say what the issue was.

  6. Koraktor July 4th, 2008 1:14 am

    Restarting the server fixed it for me.

    I already had Mongrel 1.1.5, downgrading Rails wasn’t an option and other solution suggestions like changing routes etc. didn’t help.

    Nevertheless this seems to be a route caching problem in Rails 2.1.0.

  7. Chris Nolan.ca July 5th, 2008 10:04 am

    FYI,

    I’ve been getting this (minus the head) on my facebook apps. I changed the request_method_with_facebooker method which used the facebook parameter fb_sig_request_method to mask the POST FB makes to a get — needed to do the same thing for the HEAD as well.

    Hopefully that’ll help someone else too.

  8. […] be nice to know how widespread this problem is. This link talks about this same issue in the comments. The main post is a little confused […]

  9. David August 11th, 2008 2:02 am

    I had the same problem too, but it turned out that I had not not mapped my resources properly.

    map.resource ‘/your_controller’

    fixed this just fine

Leave a comment