Tiger Technologies Technical Support

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

To freeze the RubyGems for an application:

cd html
cd railstest
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.0.2:

rake rails:freeze:edge TAG=rel_2-0-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 1.2.5 to ensure stability. When you became aware of a Rails upgrade (version 1.2.6 became available), you could upgrade your frozen version of Rails during an off-peak hour:

rake rails:freeze:edge TAG=rel_1-2-6

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 TAG=rel_1-2-5

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

script/about

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:configs

Search


Related Topics

Unix Shell (telnet and SSH) Access

Ruby and Rails