Exciting times in Rails land
Courtenay : March 29th, 2008
Lots of really cool fixes and features are going into Rails right now. I’m sure you all subscribe to Ryan Daigle’s “What’s new in Edge Rails” at http://ryandaigle.com/—if you don’t, go do it right now.
One of the advantages of having a Rails core committer on the team at ENTP is that we get to drink from the firehose of pain that is edge rails. Many a Campfire discussion ends like this: “There’s this new feature which will solve this problem”, says Rick, “but we’ll have to move to Edge”.
Anyway, it looks like 2.1 is on the horizon, which means lots of updates as they get to pushing it out the door. Here are some of the awesome new features:
Timestamped migrations
Migrations will soon have a UTC timestamp instead of a number, so it’ll be much easier to merge in branches and fix your migrations without errors.
named_scope
named_scope is a way of providing association-like scopes to your models, so you can define things like
named_scope :visible, :conditions => { :visible => true }
User.visible.find :first
which, in my opinion, is much better than with_scope, because it helps you to look for a method called ‘visible’ rather than “find_visible”, which is some nasty meta guff.
Dirty field checking
You’ll be able to check, and commit, changes to single fields, rather than updating entire rows. This is still shiny-new, and I haven’t had a chance to use it yet, but here’s a sample from the feature’s tests:
person.name = 'a'
assert person.name_changed?
config.gem
You can specify which gems are required by your application in the “config” section. The extra bonus with this is the new rake task, rake gems:install which will automagically install the required gems for you. Seriously, this is freakin’ awesome.
Ripped from the CHANGELOG:
Rails::Initializer.run do |config|
config.gems "bj"
config.gems "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
config.gems "aws-s3", :lib => "aws/s3"
end
rake gems # lists gems
rake gems:install # Install all required gems:
rake gems:unpack GEM=bj # Unpack specified gem to vendor/gems/gem_name-x.x.x
Gems can be plugins
If your plugin has the file, rails/init.rb, it will now work cleanly as a plugin.
OpenID plugin updated
The OpenID auth plugin now uses version 2 of the gem, which is a major leap forward.
Massive documentation patch
Pratik’s rails-documentation github project is certainly a lively one; look forward to some Doc Project updates over the coming weeks on this front. Now that Rails core has some more, dedicated doc-loving committers, Rails docs will be progressing at a major pace.
Phew. What an update! The upgrade from 2.0.2 to 2.1 will certainly be an interesting one for us all.
Oh, and Ryan? Scoop!
11 Responses to “Exciting times in Rails land”
Sorry, comments are closed for this article.
March 30th, 2008 at 05:16 AM
Nice update. The config.gems + rake tasks is a welcome idea.
March 30th, 2008 at 08:07 AM
That should actually read config.gem
March 30th, 2008 at 09:49 AM
Awesome update. The amount of pain we have with migrations and gems when deploying is crazy. Loving this!
March 30th, 2008 at 11:16 AM
This is all great stuff, and I'm really happy that we're seeing very regular gem releases of Rails. I prefer to avoid running on Edge, but it can get frustrating when you want to get at those brand new features.
March 30th, 2008 at 11:23 AM
Doh, the config.gems typo was my fault in the CHANGELOG. Fixed. Thanks.
March 30th, 2008 at 01:25 PM
Nice to see the dirty field checking. I'll have to poke around to see how things like record.field.gsub!(...) are handled.
March 30th, 2008 at 06:13 PM
Once again Rails makes my life a little easier. Brilliant!
March 30th, 2008 at 08:04 PM
Something wrong?
added to environment.rb config.gem 'rmagick', :lib => 'rmagick', :version => '2.2.2'
script/server
Exiting ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:13:in
initialize': undefined methodrequirements' for #<gem::requirement:0xb798e1f0> (NoMethodError)March 30th, 2008 at 10:15 PM
Awesome news. Very welcome additions indeed. Anyone has any idea when the 2.1 tag will be in place?
March 31st, 2008 at 01:57 AM
config.gem is brilliant.
March 31st, 2008 at 08:02 PM
config.gem is a welcome idea!
I'm especially thankful for the :source option. In more cautious development environments, folks get pretty nervous when resources (gems, plugins, etc.) are completely out of your control. If a business client hears that a deploy didn't work out because we are dependent on svn://foo.com from being online and responsive, we've got badness.
With this, it's possible to maintain a local gem "mirror" of the various gems (and their versions) that are used, and source them from there.