Freeze and Unfreeze Rails application

Ruby on Rails allows you to “freeze” the version of Rails used by your application. When you freeze Rails, your application will always use that version of Rails and the associated Ruby Gems, regardless of what version is installed on the server. You can choose which version of Rails you want to freeze to.

Freezing Rails is recommended if you are using a Rails application for a business site or another production environment where stability is the most important concern. If you don’t freeze your application, there is a small possibility that your application might stop working due to compatibility problems when a new version of Rails is installed on our servers.

However, keep in mind that if you freeze your application to use a current (or older) version of Rails, you will not get the security benefits of automatic upgrades. You should make sure you’re keeping track of Rails versions yourself (for example, by subscribing to the Rails mailing lists) and upgrading your frozen version of Rails as necessary.

Freezing Rails

Run the following command to freeze this application to the version of Rails that is currently on our servers:
rake rails:freeze:gems

This will copy the Rails files to the “vendor/rails” directory of your application. When the Rails framework runs, your application will first check for the presence of this directory. If it exists, Rails will load the Rails components from the directory instead of using the main server copy of Rails. As long as you do not delete these files, your application will continue to use your “frozen” version of Rails.

Unfreezing (thawing?) Rails

If you decide you want to switch back to the server’s main copy of Rails, you can remove the frozen version with this command:
rake rails:unfreeze

Freezing to a different version

Although we’ve explained how to freeze Rails to the current version on the server, Rails allows you to freeze to almost any version.

For example, this command freezes your application to Rails 2.2.2:
rake rails:freeze:edge RELEASE=2.2.2

Leave a comment