Incrementally upgrade rails 4.1 to 4.2

Hi Everyone,

Can you assist me with the syntax to incrementally upgrade rails 4.1 to 4.2?

Thanks,

I'm not sure what "syntax" is in this context, but upgrading is just a matter of editing your project Gemfile and running `bundle update`.

And of course fixing deprecation warnings and errors and whatnot :grinning:

I do not have an app on the machine yet. I just installed rails 4.1 and I wanted to do an incremental upgrade prior to placing the preexisting app on the machine.

I do not have an app on the machine yet. I just installed rails 4.1 and I wanted to do an incremental upgrade prior to placing the preexisting app on the machine.

Any modern Rails app will use bundler, and therefore have a Gemfile that specifies which version of Rails it expects. If you cd into the directory with the application, and type bundle install, then the right version of Rails and all dependencies will be installed.

Then, assuming your tests pass, you can create a new git branch, edit the Gemfile to point to a newer version of Rails, and run bundle update rails. That will give you the new Rails and any dependencies that were changed by the update.

You then have a coin-flip chance that the app will pass its tests, depending on how large a change you made.

For a start on fixing the differences, you can then run rake rails:upgrade or rails app:upgrade, depending on which version of Rails you’ve moved to, and that will perform all sorts of automated fixes. It will probably also break some things, too.

It’s really worthwhile to read the Rails Guide on upgrading. It covers best practices and has lots of helpful hints to debug the changes.

Walter

Thank you Walter.