In some Rails 3 application, I get a somewhat cryptic message in my development log file :
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/
I’ve read the designated article on the (great) EngineYard blog, but I didn’t find anything wrong in my routes file.
I searched for the message in ActionPack source code, found a call to DeprecatedMapper, then search for that and found something interesting in route_set.rb. In the « draw » method, there is a check on the block « arity« . WTF is arity ?
The arity method exists on Proc objects to check for « the number of arguments that would not be ignored » (straight from the Ruby documentation).
I understood that the route file must not have any argument in the main (draw) block.
I had to change this
MyApp::Application.routes.draw do |map| (…) end
MyApp::Application.routes.draw do (…) end
It’s as simple as that, and then I didn’t have deprecation messages for my router’s syntax anymore.
I guess it wasn’t so easy to find because in EY’s blog post, there is no example with the Proc definition (and only one in the official guide), only examples of routes themselves.
Update : I’ve just found out that there was already a comment on EY’s blog about this exact issue. I guess I’ve not search enough :-/