Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade a Rails 3.0 app to Rails 3.1?

I have a Rails 3.0 app (technically 3.0.7) which I would like to upgrade to Rails 3.1 to make use of the new asset pipeline and other fancy new features. What is the best approach to doing this? Should I use the rails new generator, then copy everything from my old app over to the new one? What about version control? I already have my old app using Git.

like image 942
Andrew Avatar asked Feb 03 '23 14:02

Andrew


2 Answers

Just upgraded one of my apps from 3.0.9 to 3.1.0, here's my approach, your mileage might vary:

Edit Gemfile, change Rails gem version

gem 'rails', '3.1.0'

Also adds new gems introduced in 3.1.0

group :assets do
  gem 'sass-rails', "~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end
gem 'jquery-rails'

run bundle update rails

Then run rake rails:update and resolve conflicts.

Move your css/javascript/images etc to app/assets folder, make sure there's an application.js and an application.css file (you might want to take a look at those two from newly created 3.1.0 projects)

Include css/javascript links in your layout file like this

<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
like image 196
Forrest Ye Avatar answered Feb 05 '23 16:02

Forrest Ye


Get familiar with rails 3.1, here are the resources: http://jasonrudolph.com/blog/2011/06/06/helpful-resources-for-upgrading-to-rails-3-1/

The most important thing are your current test, make sure you have a good test coverage of your 3.0 app before you start.

like image 39
daniel Avatar answered Feb 05 '23 16:02

daniel