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.
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" %>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With