How to upgrade an existing application to 2.2.2?

I apologize for asking such a basic question, but I have a RoR application I started developing last July and would like to continue working on it now. Since that time, I have updated my rails version to 2.2.2 and, since I really don’t have anything to lose, would like to update this (previously 2.1.0) application to 2.2.2.

I tried running:

$ rake rails:upgrade

and nothing happened (as verified by git)

So then I tried editing config/environment.rb and changing RAILS_GEM_VERSION to 2.2.2 and then running:

$ rake rails:upgrade

and now things have changed.

Is it really as simple as that?

Where should I have looked for documentation about this? (If such documentation doesn’t exist, I would be glad to add it, but I fear that it would be as simple as the 2 sentences shown above.)

–wpd

Hi Patrick,

what does your tests/specs tell you? Do they pass?

Regards Nicolai

Make that “What Do your tests/spec tell you?”…

Sorry about that.

$ rake -T rails

shows an update task but not an upgrade one (in my 2.1.1 app). The rails:update task only updates “configs, scripts and public/javascripts from Rails.” It doesn’t update Rails itself. If you have Rails in vendor/rails, then you’ll have to replace that w/ 2.2.2. If you’re depending on gems, then it should be as easy as setting RAILS_GEM_VERSION and running rake rails:update. Now, that doesn’t mean that your app will work or your tests/specs will pass. You may have to make some changes.

Regards, Craig

I forgot to mention that all of the tests pass before and after running the

$ rake rails:update

The main reason that I forgot to mention that was that, ummm… erhhh…

Well, you see, at the time I wrote that, it wasn’t strictly true. But now it is :slight_smile:

And yes, Craig, that should have been “rake rails:update” not “rake rails:upgrade”… that was a silly typo on my part. Also, I had previously used gem to update my rails installation.

So now, I would like to go add a page to the Wiki that says something like:

If you want to update to a newer version of Rails, here is what you should do:

  1. Run “rake test” and make sure that all of your tests pass.

  2. Ensure that you have the newer version of Rails installed (e.g. via “gem update”)

  3. Check in your code using your favorite SCMS.

  4. Edit config/environment.rb and set RAILS_GEM_VERSION to match the version of Rails to which you wish to update

  5. run “rake update” to update the configuration files (such as boot.rb and environment.rb), scripts, and javascript files to reflect the newer version of Rails.

  6. run “rake test” to make sure that all of your tests still pass

  7. Fire up your browser and make sure things look “normal” (for suitable definition of “normal”).

Does this sound about right to folks? Is there any reason (within reason) that this same procedure couldn’t be used to downgrade an application (say, for example, if you wanted to use a plugin that only worked with 2.1.0, and you had been developing in 2.2.2)? I wouldn’t expect it to work to switch from 2.2.2 to, say, 0.3.1, but it seems like it ought to work for anything in the 2.x.y series.

–wpd

So now, I would like to go add a page to the Wiki that says something like:

If you want to update to a newer version of Rails, here is what you should do:

1) Run "rake test" and make sure that all of your tests pass. 2) Ensure that you have the newer version of Rails installed (e.g. via "gem update") 3) Check in your code using your favorite SCMS. 4) Edit config/environment.rb and set RAILS_GEM_VERSION to match the version of Rails to which you wish to update 5) run "rake update" to update the configuration files (such as boot.rb and environment.rb), scripts, and javascript files to reflect the newer version of Rails. 6) run "rake test" to make sure that all of your tests still pass 7) Fire up your browser and make sure things look "normal" (for suitable definition of "normal").

Does this sound about right to folks? Is there any reason (within reason) that this same procedure couldn't be used to downgrade an application (say, for example, if you wanted to use a plugin that only worked with 2.1.0, and you had been developing in 2.2.2)? I wouldn't expect it to work to switch from 2.2.2 to, say, 0.3.1, but it seems like it ought to work for anything in the 2.x.y series.

--wpd

Worked out perfect for me. I updated a Rails 2.1 (Restful Authentication with all the bells and whistles (new 9/05/08)) app to enable ActiveScaffolding (which works only on rails 2.2. Tnx.