Upgrading to Rails 3: You are using the old router DSL which will be removed in Rails 3.1

August 30th, 2010 at 1:28 pm • permalink1 comment

You upgraded your Rails 2 application to Rails 3, you changed all the routes to match the new Rails 3 syntax, but Rails is still throwing the following deprecation message.

DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from /Users/weppos/Sites/working/simonecarletti/config/routes.rb:1)

The solution is really straightforward, just around the corner, but you need to be good enough playing “spot the difference” game. If you’re not, here’s the trick.

Make sure the #draw block at the beginning of your routes.rb file doesn’t yield any |map| parameter. In fact, this statement will cause the warning

1
Simonecarletti::Application.routes.draw do |map|

while this one won’t.

1
Simonecarletti::Application.routes.draw do

Needless to say, remove the map parameter only when you wiped out all the legacy routes. Otherwise your application won’t work at all.

  1. Upgrading Rails 2 application to Rails 3 (screencast)
  2. Upgrading to Rails 3: Beware of the Object#tap pattern
  3. The Road to Rails 3: make your Rails 2.3 project more Rails 3 oriented
  4. Unobtrusive JavaScript in Rails 3
  5. User profile permalinks with Ruby on Rails (and Authlogic)

Filed in Programming • Tags: , ,

Comments

Damien White says:

Thanks for this. Such a simple solution, but I didn’t catch the difference until I found your post. Thanks again.

-Damien

Add a Comment




Follow Me
    Random Quote