Rails 2.2 is almost here

The next major release of Rails is just about ready. There’s a ton of improvements. If you do stuff with Rails, it’s worth checking out the release notes.

One of the prettiest little things is this one:

5.4.2. find_by_!

The new bang! version of find_by_! is equivalent to +Model.first(:conditions ⇒ {:attribute ⇒ value}) || raise ActiveRecord::RecordNotFound Instead of returning nil if it can’t find a matching record, this method will raise an exception if it cannot find a match.

# Raise ActiveRecord::RecordNotFound exception if 'Moby' hasn't signed up yet!
User.find_by_name!('Moby')

which means there’s no need to manually raise ActiveRecord::RecordNotFound when you’re using a dynamic finder. Nice!