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.
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.
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 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.
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.
The Axioms of Software Development – Part 5
Is it worth upgrading your Rails application?
The Axioms of Software Development - Part 4
reinteractive is Australia’s largest dedicated Ruby on Rails development company. We don’t cut corners and we know what we are doing.
We are an organisation made up of amazing individuals and we take pride in our team. We are 100% remote work enabling us to choose the best talent no matter which part of the country they live in. reinteractive is dedicated to making it a great place for any developer to work.
Webinars are our online portal for tips, tricks and lessons learned in everything we do. Make the most of this free resource to help you become a better developer.
The Ruby on Rails Installfest includes a full setup of your development environment and step-by-step instructions on how to build your first app hosted on Heroku. Over 1,800 attendees to date and counting.
The Ruby on Rails Development Hub is a monthly event where you will get the chance to spend time with our team and others in the community to improve and hone your Ruby on Rails skills.