Upgrading from Rails 3 to Rails 3.1

How do you upgrade Rails 3 beta to Rails 3.1?

+61
ruby ruby-on-rails ruby-on-rails-3
May 11 '11 at 17:23
source share
9 answers

This is what worked for me when upgrading an existing rails 3.0.8 project. Your mileage may vary ...

Update the version of rails indicated in my Gemfile to use the latest release:

gem 'rails', '3.1.0.rc4' 

Update package:

 bundle update 

Then update the project with the rake command:

 rake rails:update 

After the cherry gathered although a conflict of changes, I ran all my tests and they passed (yay!). I restarted the server and everything seems to be good so far.

However, this is not yet using the conveyor of new assets. By this I mean that javascript and css (or sass) files are still processed according to the preliminary pipeline. As far as I understand, this is a viable option. But, of course, I want new kindness, so I believe that the next steps include additional gems (e.g. coffeescript, sass, uglifier, etc.), and then transfer the old files to the application / asset directory.

I found some details about what's here:

http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/

Hope this was helpful.

+54
Jun 15 '11 at 23:14
source share

I just upgraded from 3.0 to 3.1 by changing my Gemfile to:

 gem 'rails', '3.1.0.rc1' gem 'sqlite3' gem 'sass' gem 'coffee-script' gem 'uglifier' 

I also commented on the following line below in config / environment / development.rb

 # config.action_view.debug_rjs = true 

Finally, make sure you include the asset pipeline in config / application.rb

 config.assets.enabled = true 

I'm not sure that you have already read the release notes for http://weblog.rubyonrails.org/2011/4/21/jquery-new-default

+28
May 24 '11 at a.m.
source share
+24
May 11 '11 at 17:29
source share

Rails Update

Update : be careful when using the system rake since the rake has been updated.

 bundle exec rake 

ensures that you will use the correct rake for this rails project ( source )




I suggest starting with a fresh application, and then copying it into your specific application information, moving your resources to the new asset / star format.

Example

When converting old rails 2.3.4 app to 3.0 I crashed and burned while changing one file at a time within the project. Of course, this was an incorrect strategy, but I did a little study on this path. I ended up skipping 3.0 and moving to 3.1beta1 with a fresh application, and copied my application and public folders after getting the migration to the right. This step has a couple of unresolved issues, most importantly, that I did not use rails to create a new application (thanks for the tip of RubyInside).

First hook the last rails for easy orientation:

cd ~/goodtimes

git clone https://github.com/rails/rails.git

My path includes ~ / Desktop / Dropbox / so my code is available everywhere.

Then refer to rails exec to create a new application:

~/goodtimes/rails/bin/rails new bacon --edge

Depending on the complexity of your database, you either want to create new migrations using the change syntax, or leave them:

  class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| t.string :title t.text :body t.timestamps end end end 

I had a deployment problem in Heroku, but the RubyRacer jewel helped to avoid this. Here is an example of a simple gem file:

 source 'http://rubygems.org' gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Asset template engines gem 'sass' gem 'coffee-script' gem 'uglifier' gem 'jquery-rails' gem 'pg' gem 'therubyracer-heroku', '0.8.1.pre3', :platforms => :ruby # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' group :test do # Pretty printed test output gem 'turn', :require => false end 

I suspect there will be community utilities to help you automate the migration from older versions of Rails to -edge.

Literature:

+13
May 17 '11 at 17:48
source share

I recommend updating the Gemfile to use rails. For example:

 gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'arel', :git => 'git://github.com/rails/arel.git' gem 'rack', :git => 'git://github.com/rack/rack.git' gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git' gem 'sqlite3' # Asset template engines gem 'sass', '~> 3.1.0.alpha' gem 'coffee-script' gem 'uglifier' 

You can read it here http://pogodan.com/blog/2011/04/24/easy-edge-rails .

+3
May 11 '11 at 18:59
source share
+2
Oct 29 '11 at 11:16
source share

If I understand your question correctly, here's how:

 gem install rails --pre 
+1
May 11 '11 at 17:26
source share

This is a pretty good guide detailing how to install Rails 3.1:

http://railsapps.github.com/installing-rails-3-1.html

+1
Aug 16 2018-11-11T00:
source share

Upgrading rails 3.0.7 and 3.0.9 using this guide worked for me

http://davidjrice.co.uk/2011/05/25/how-to-upgrade-a-rails-application-to-version-3-1-0.html

You can skip steps 3 and above if you want - it will still work, although you will not use everything new in rails 3.1.

0
Sep 13 2018-11-11T00:
source share



All Articles