Sarav's Weblog

Technical Articles for RoR Developers

Should I freeze my 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.

On this page:

  • * Freezing Rails
  • * Unfreezing Rails
  • * Freezing to a different version

Freezing Your Application

cd "application path of your system"
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.

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

And this freezes Rails to the current development version:

rake rails:freeze:edge

The ability to freeze to different versions of rails can be useful when upgrading. For example, imagine you created a new Rails application and froze it to version 2.2.3 to ensure stability. When you became aware of a Rails upgrade (version 2.3.4 became available), you could upgrade your frozen version of Rails during an off-peak hour:

rake rails:freeze:edge RELEASE=2.3.4

Then you’d test your application to ensure it worked properly. If so, you’re all set, with the latest version of Rails installed. If not, you could downgrade back to the previous version until you were able to fix the problem, using:

rake rails:freeze:edge RELEASE=2.2.3

By the way, you can tell what version of Rails your application uses with this command:


Finally, some Rails upgrades provide configuration file changes (in particular, changes to “config/boot.rb”). To get the benefit of these changes, run this command after switching Rails versions:

rake rails:update


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: