English 中文(简体)
Upgrading from Rails 3 to Rails 3.1 [closed]
原标题:
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it s on-topic for Stack Overflow.

Closed 10 years ago.

How do you upgrade from Rails 3 to Rails 3.1 beta?

问题回答

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

Update the rails version specified in my Gemfile to use the latest release candidate:

gem  rails ,  3.1.0.rc4’

Update the bundle:

bundle update

Then update the project with the rake command:

rake rails:update

After cherry picking though the change conflicts I ran all my tests and they passed (yay!). I restarted the server and everything seems good so far.

However, this is not using the new asset pipeline yet. By that I mean the javascript and css (or sass) files are still being handled in the pre-pipeline manner. As I understand it, this is a perfectly viable option. But of course, I want the new goodness, so I believe the next steps are to include and additional gems (e.g. coffeescript, sass, uglifier, etc) and then to migrate the old files to the app/assets directory.

I found some details about that are here:

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

Hope that was helpful.

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 out the following line below in config/environments/development.rb

# config.action_view.debug_rjs = true

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

config.assets.enabled = true

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

Upgrading Rails

Update: be cautious of using your system rake, as rake has been upgraded.

bundle exec rake

ensures you ll be using the correct rake for a given rails project (source)


I suggest beginning with a fresh app, then copying in your specific app information while shifting your resources into the new asset/sprockets format.

An example

While converting an older rails 2.3.4 app to 3.0 I crashed and burned while changing one file at a time over within the project. Needless to say that was a flawed strategy, but I did learn a little along the way. I ended up skipping 3.0 and moving to 3.1beta1 with a fresh app, and copied my app and public folders in after getting the migrations right. That move had a couple of outstanding issues, the most important being that I didn’t use rails edge for creating the new app (thanks for the tip RubyInside).

First snag the latest rails into an easy to reference location:

cd ~/goodtimes

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

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

Then refer to that rails exec for building a new app:

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

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

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

        t.timestamps
      end
    end
  end

I had an issue deploying to Heroku, but theRubyRacer gem helped square that away. Here s 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 migration from older versions of Rails to the --edge.

References:

  1. How to Play with Rails 3.1, CoffeeScript and All That Jazz Right Now
  2. The Four Horsemen of Rails 3.1beta, Coffee-Script, jQuery, SCSS and Assets
  3. Rails 3.1beta deployed to Heroku from your iPhone
  4. Reversible Migrations

I recommend updating your Gemfile to use edge 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 more here http://pogodan.com/blog/2011/04/24/easy-edge-rails.

If i understood your question correctly this is how:

gem install rails --pre




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签