Ruby on Rails 4.0 Release Notes

Highlights in Rails 4.0:

These release notes cover only the major changes. To learn about various bug fixes and changes, please refer to the change logs or check out the list of commits in the main Rails repository on GitHub.

Chapters

  1. Upgrading to Rails 4.0
  2. Creating a Rails 4.0 application
  3. Major Features
  4. Extraction of features to gems
  5. Documentation
  6. Railties
  7. Action Mailer
  8. Active Model
  9. Active Support
  10. Action Pack
  11. Active Record
  12. Credits

1 Upgrading to Rails 4.0

If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 3.2 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 4.0. A list of things to watch out for when upgrading is available in the Upgrading Ruby on Rails guide.

2 Creating a Rails 4.0 application

 You should have the 'rails' RubyGem installed
$ rails new myapp
$ cd myapp

2.1 Vendoring Gems

Rails now uses a Gemfile in the application root to determine the gems you require for your application to start. This Gemfile is processed by the Bundler gem, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.

More information: Bundler homepage

2.2 Living on the Edge

Bundler and Gemfile makes freezing your Rails application easy as pie with the new dedicated bundle command. If you want to bundle straight from the Git repository, you can pass the --edge flag:

$ rails new myapp --edge

If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the --dev flag:

$ ruby /path/to/rails/railties/bin/rails new myapp --dev

3 Major Features

Rails 4.0

3.1 Upgrade

3.2 ActionPack

3.3 General

Check that the gems you are using are threadsafe.

3.4 Security

4 Extraction of features to gems

In Rails 4.0, several features have been extracted into gems. You can simply add the extracted gems to your Gemfile to bring the functionality back.

5 Documentation

6 Railties

Please refer to the Changelog for detailed changes.

6.1 Notable changes

6.2 Deprecations

7 Action Mailer

Please refer to the Changelog for detailed changes.

7.1 Notable changes

7.2 Deprecations

8 Active Model

Please refer to the Changelog for detailed changes.

8.1 Notable changes

8.2 Deprecations

9 Active Support

Please refer to the Changelog for detailed changes.

9.1 Notable changes

  # ActiveSupport 3.x
  "asdf".to_date # => NoMethodError: undefined method `div' for nil:NilClass
  "333".to_date # => NoMethodError: undefined method `div' for nil:NilClass

  # ActiveSupport 4
  "asdf".to_date # => ArgumentError: invalid date
  "333".to_date # => Fri, 29 Nov 2013

9.2 Deprecations

10 Action Pack

Please refer to the Changelog for detailed changes.

10.1 Notable changes

10.2 Deprecations

11 Active Record

Please refer to the Changelog for detailed changes.

11.1 Notable changes

11.2 Deprecations

12 Credits

See the full list of contributors to Rails for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.