I really like doing Rails work, but if there is one pet peeve that I have, it’s moving between Ruby on Rails versions. There are a fair number of Ruby apps out in the wild, and when handed a Rails app to start maintaining, you need to move from version to version. Of course, what’s interersting is how to check for the different rails versions. For example, some people think doing this will work:
That does work, IF you are not using the vendor/rails version of rails. However, this means that you have to know what rails version you’re developing for. This becomes a major pain for certain tags that are simply ignored in Rails 1.1 and are rendered in Rails 1.2. Days can be done developing in Rails 1.2 before deploying on another site, and if you don’t know that you’re running Rails off of vendor/rails, this could be a major problem.
So, how do you determine which rails you’re running?
One way to do it is to go into the console, and run this:
This will load what the application environment sees as its version of rails, which is much more useful than the previous command. However, if you run this command:
You’ll see the Ruby version of phpinfo(), which will give you all the information that you need to rock and roll. There are cases where you may want to downgrade to a prior version, namely if you’re using a plugin that requires a certain syntax in a previous version. However, there’s arguments for and against this behaviour. I would always use the latest version of rails, mainly because it’s easier to give to someone else who’s not as experienced with Rails, and it’s better to have them learn how to use the latest version as opposed to trying to find documentation for previous versions of rails.
So far, I have to say that going between versions of rails is one of the most frustrating things that I’ve found so far with Ruby on Rails.