Here I highlight my top five features:
Rails Mass assignment feature is quite handy but can be really dangerous. Last year Github was compromised by an attack based on it. Rails 4 has a new way of dealing with mass assignment each basically pushes the responsibility out of the model and into the controller where it belongs.
Rails 4 brings Lives Streaming as a major new feature. To enable streaming we need to mixin the
ruby ActionController::Live to the controller class. One use case for this is to enable push notifications to the frontend without relying on plugins like Juggernaut or outside services such as Pusher.
Russian Doll caching
Russian Doll caching describes the technique of using nested fragment caching. The idea is that a page can best divided multiple sections, each one being a fragment. These cached fragments are used independently and can be reused when the content changes. Changes to inner fragments caused a chain reaction which expires all outer fragment caches. Rails 4 uses caches digests to avoid the pain of maintaining cache version numbers for individual templates.
You can read more about Russian Doll caching here
Asynchronous Action Mailer
A new Queue framework was added to Rails 4 and Action Mailer are configured by default to use this new Queue interface. The interface remains very similar to Rails 3 developers with the added benefit that changing backend providers is as easy as changing a single line of code:
1 2 3 4
You can read more about this feature here
Other smaller enhancements
Rails 4 is now thread-safe by default. You can read about this change on this helpful post by Aaron Patterson.
Another addition is Turbolinks which works similarly to pjax, fetching relevant content and updating the page to avoid a full reload. Read more about it here
There are many more features that I will not be able to cover here. You can read the releases notes to see the detailed changes.
Rails 4.0.1 brings some stability improvements to Rails 4. The complete set of changes are shown here