Rails 4.1 was released on April 8th and subsequently Lucas Mazza from plataformatec blogged about 3 favourite features in Rails 4.1. I liked the idea, but some of my favourite things are different.

Without further ado, here's my favourite things about Rails 4.1.

No more rake db:test:prepare

One common busy-task which occupies Rails developers during development is keeping the test database migrated in-line with the development database. This involves running rake db:test:prepare every time you want to run tests after you've run a migration.

In Rails 4.1 there's a "magical" line which can be added to your test or spec_helper.

ActiveRecord::Migration.maintain_test_schema! if defined?(ActiveRecord::Migration)

This line of code effectively runs the rake db:test:prepare code before your test run so you can be certain that you're testing against the most recent database schema.

At time of writing though, this line isn't added to your spec_helper by rspec-rails, although it has landed in master so it should be landing on rubygems.org soon.

ActionMailer Previews

Building HTML emails is something which is required for nearly every Rails project we work on. Being able to preview emails in development is a huge time-saver over the "standard" technique of constantly sending the email and opening it in your browser or using something like the ecellent MailCatcher.

The documentation is available at: http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Previewing+emails

This is based on the mail_view gem which we've been using on some of our current applications. We've also set it up so that the mail previews are available in the staging environment which we can use to show our client how the actual email will look when it is delivered.

Spring

Spring is an application pre-loader similar to Zeus. It makes running tests, rake or loading up the rails console significantly faster. It works by keeping your Rails application loaded in the background and reloading it intelligently based on which files you update. In my experience it works extremely well, and makes the simple task of runing rake routes much faster.

In conclusion

There's a lot to like about Rails 4.1. It might be a "minor" release, but there's some seriously awesome progress still being made by the Rails community. So perhaps my most favourite thing is that after all these years Rails is still innovating and making the framework better for everyone.