This blog post documents the process of upgrading Qrious app to Rails 3.1.0.rc4. While certain errors may be application/gems specific, I hope the overall approach may be usefull to other application.
The process was split into two stages
There is more then one way to do it. And, as a helper, generate a new rails 3.1 application and refer to its Gemfile and config files for reference.
The initial attempt was to simply include rails 3.1 gems in Gemfile
gem 'rails', '3.1.0.rc4' gem 'sass-rails', "~> 3.1.0.rc" gem 'coffee-script' gem 'uglifier' gem 'jquery-rails'
and update the project with
bundler update rails:
$ bundle update rails Bundler could not find find gem activesupport (= 3.1.0.rc3, runtime), which is required by gem multi_json (~> 1.0, runtime).
Boom! Bundler could not resolve dependencies. It seems some other gem depends on multi_json gem with too narrow constraint on the version. (I later discovered it was linkedin gem).
$ bundle install Fetching source index for http://rubygems.org/ You have requested: rails ~> 3.1.0.rc4 The bundle currently has rails locked at 3.0.9. Try running `bundle update rails`
Vicious cycle. I could have dug into the previously stable Gemfile.lock trying to manually track down the mismatched dependencies, but that did not seem like a particularly robust approach, especially since this unresolved dependency may not be the last.
Anothep approach you may try, is to comment out all gems in Gemfile except rails 3.1, update rails, and then uncomment gems one by one and deal with errors.
The approach that finally worked for me was to rename the gemset (you are using rvm, aren’t you?) to something else for reference and create an empty gemset with the original name. Then try to install the updated Gemfile with bundle install. (Delte Gemfile.lock before this).
This is a cleaner approach with a disadvantage that the other gems which had no version constraint specified in Gemfile will be installed with the latest version, and that may not be what you want. To mitigate it, take a look at your pre-3.1 Gemfile.lock and put a version constraint for the gems you dont want upgraded.
Once the gems are installed, run the tests and go through the tests output and fix deprecation warnings.
You can also run the app with the assets pipeline disabled to make sure nothing is broken with the gems upgrade. Inside config/application.rb put:
# Disable the asset pipeline for now config.assets.enabled = false # <== this is temporary
At theis point your application should be working as before the upgrage, with assets pipeline disabled.
undefined method `debug_rjs=' for ActionView::Base:Class
This option was removed in rails You will need to remove a reference to it from config/environments/development.rb
If you are on *nix machine you may get:
sudo apt-get install nodejs
Right now is a good time to generate a new rails 3.1 application and compare/diff the generated files under config folder with your application.
For my application I had to do the following changes:
Replaced config/boot.rb with the one generated by rails 3.1
In config/application.rb added the following line.
# Enable the asset pipeline config.assets.enabled = true
In config/environments/development.rb removed the following line:
config.action_view.debug_rjs = true
Copy over config/initializers/wrap_parametes.rb
Added the following lines to config/environments/development.rb
# Do not compress assets config.assets.compress = false
Added the following lines to config/encironments/test.rb
# Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600"
Added the following lines to config/environments/production.rb.