The Rails 3.1.0 Release Candidate dropped a few days ago and thought I’d give it a try on an application I was busy upgrading already. Before starting you’ll probably want to check out the Release Notes or the railscasts overview video first.
1. Upgrade the Gemfile
Needed specifically the latest version of mysql2 as the earlier ones are incompatible. To get the asset pipeline working on heroku you’ll need therubyracer-heroku. Another issue with heroku, it appears you now need to be explicit about using postgres in production.
2. Config File Changes
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
In config/application.rb add the following line.
# Enable the asset pipeline config.assets.enabled = true
I seemed to have to remove the following line from config/environments/development.rb
config.action_view.debug_rjs = true
Add the following lines to enable asset compression in config/environments/production.rb.
3. Move Assets
Move the Folders
Fix Image References
Use your favourite find and replace, check judiciously.
find: /images/ replace: /assets/
I did the same for app/assets/application.css
/* * This is a manifest file that'll automatically include all the stylesheets available in this directory * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at * the top of the compiled file, but it's generally better to create a new file per style scope. *= require_self *= require_tree . */
Instead of requiring multiple files you’ll want to require the manifest files created above.
On an app with good front end conventions established, already using a method of asset bundling, etc. this isn’t a big task.
However I do find that because Rails has set such good conventions it’s hard for people to go too wrong. Of all the applications where I’ve taken over from another developer over the years. Rescue missions, etc. It’s the prospect of looking in the public/ directory that scares the bajaysus out of me.
Thankfully with all this great new front end stuff I’m hoping that in the future, rescue missions into interface land will suffer less casualties.