After six months of polish, four betas, and two release candidates, Rails 5.0 is finally done! It’s taken hundreds of contributors and thousands of commits to get here, but what a destination: Rails 5.0 is without a doubt the best, most complete version of Rails yet. It’s incredible that this community is still going so strong after so long. Thanks to everyone who helped get us here.
The two star features of Rails 5.0 are as follows:
What’s really lovely about Action Cable is that you get access to your entire Active Record and PORO domain model in your WebSockets work. We even added a brand-new ActionController::Renderer system that makes it trivial to render your templates outside of controllers, when you want to reuse server-side templates for WebSocket responses.
In development, Action Cable runs in-process with the rest of your app. To do this, we’ve switched the default development server from Webrick to Puma. In production, you may well want to run Action Cable servers in their own processes. That’s how we run it at Basecamp at scale.
rails new backend --api, you’ll get a slimmed down skeleton and configuration that assumes you’ll be working with JSON, not HTML.
There’s still more work to be done on this feature, but we’re off to a great start. By default, API mode just relies on
#to_json calls on model classes. But you can either use Jbuilder, Active Model Serializers, or look at the new JSONAPI::Resources project for a more advanced solution.
- One Rails Command instead of the split-brain setup between rake and rails, so now it’s
bin/rails db:migrateinstead of
bin/rake db:migrate(herding by Kasper Timm Hansen).
- New Attributes API by Sean Griffin.
- The test runner now reports failures inline, so you don’t have to complete the suite to see what went wrong.
- ApplicationRecord has been born as a default parent class of all models created by the generators.
- ActiveRecord::Relation#in_batches makes it much easier to deal with record work in batches at a time to lessen memory overloads.
- Post.where(‘id = 1’).or(Post.where(‘id = 2’)) gives you exactly what you’d think!
- No more accidentally halting Active Record callbacks because the last statement is false. Now you throw(:abort) explicitly!
You should really checkout the CHANGELOGs, though. There’s just so much new and good stuff available in all the frameworks:
- Action Mailer CHANGELOG
- Action Pack CHANGELOG
- Action View CHANGELOG
- Active Model CHANGELOG
- Active Record CHANGELOG
- Active Support CHANGELOG
- Active Job CHANGELOG
- Railties CHANGELOG
Rails 5.0 also ships with Turbolinks 5 – the one with native iOS and Android wrapper implementations! If you’ve dismissed Turbolinks in the past, I urge you to checkout Sam Stephenson’s RailsConf presentation: Turbolinks 5: I Can’t Believe It’s Not Native!.
There’s even more detail in the full Rails 5.0 release notes and Claudio B. did a nice little slide deck walking through some of his favorite improvements (and removals!). And I did a brand-new let’s build a blog in Rails 5 video to demonstrate the basics.
Note: As per our maintenance policy, the release of Rails 5.0 will mean that bug fixes will only apply to 5.0.x, regular security issues to 5.0.x and 4.2.x, and severe security issues also to 5.0.x and 4.2.x (but when 5.1 drops, to 5.1.x, 5.0.x, and 4.2.x). This means 4.1.x and below will essentially be unsupported! Ruby 2.2.2+ is now also the only supported version of Rails 5.0+.