New Version of Rails, Arriving on Track 2.0
OK, title aside, no train puns from me today… this is exciting news!
Rails 2.0 has reached Preview Release status. Despite the Microsoft-esque syntax, the mood is overwhelmingly upbeat. Personally, I’ve been using Edge Rails for all my new development over the past 6 months, but this final drive by the Rails Core team and core contributors has included some great new goodies.
The changes to the Routing system have received plenty of attention elsewhere, but I wanted to pull out one tidbit which I’ve only seen posted one other place, Casper Fabricius’ excellent recap of DHH’s keynote address at Railsconf Europe:
Namespaced Routes are awesome, and a long-overdue addition for any of us who’ve attempted to create an administration section for our sites. There’s a clever bit of form_for syntax for dealing with namespaced routes.
The Old Way
form_for :user, :url => admin_users_path do |f|
# new user form
end
form_for :user, :url => admin_user_path(@user),
:html => { :method => :put } do |f|
# edit user form
end
The New Way
form_for([:admin, @user]) do |f|
# Works for either!
end
Cleaner, more concise, and thoroughly overlooked. Casper, thanks for bringing this out so we could see it!
