从Rails 3升级到Rails 3.1

时间:2022-07-20 23:11:33

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

如何从Rails 3升级到Rails 3.1 beta?

9 个解决方案

#1


54  

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

这正是我在更新现有rails 3.0.8项目时所做的。你的情况可能不同……

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

更新在我的Gemfile中指定的rails版本,以使用最新的版本候选:

gem 'rails', '3.1.0.rc4’

Update the bundle:

更新包:

bundle update

Then update the project with the rake command:

然后使用rake命令更新项目:

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.

在选择了更改后,我运行了所有的测试,然后他们通过了(yay!)我重新启动了服务器,到目前为止一切看起来都很好。

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.

然而,这还没有使用新的资产管道。我的意思是,javascript和css(或sass)文件仍在以管道前的方式处理。据我所知,这是一个完全可行的选择。但是,当然,我想要新的好处,所以我相信接下来的步骤是包括和额外的宝石(例如coffeescript, sass, uglifier等),然后将旧文件迁移到app/assets目录。

I found some details about that are here:

我在这里找到了一些细节:

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

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

Hope that was helpful.

希望是有帮助的。

#2


28  

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

我刚刚将Gemfile更改为:

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/environment /development.rb中注释了下面一行

# config.action_view.debug_rjs = true

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

最后,确保在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

我不确定您是否已经阅读了发行说明http://weblog.rubyonrails.org/2011/4/21/jquery-new-default。

#3


24  

Upgrade to Rails 3.1

升级到Rails 3.1

watch it :)

看:)

#4


13  

Upgrading Rails

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

更新:小心使用系统rake,因为rake已经升级。

bundle exec rake

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

确保在给定的rails项目(源)中使用正确的rake


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

我建议从一个新的应用开始,然后复制你的特定应用信息,同时将你的资源转换成新的资产/ spro佝偻病格式。

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).

在将一个较旧的rails 2.3.4应用程序转换为3.0时,我在项目内一次修改一个文件时崩溃和烧毁。不用说,这是一个有缺陷的策略,但我确实在这方面学到了一点。最后我跳过了3.0,用一个新的应用程序切换到3.1beta1,在正确的迁移之后复制了我的应用程序和公共文件夹。这一举动有几个悬而未决的问题,最重要的是我没有使用rails edge来创建新的应用程序(感谢RubyInside的提示)。

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

首先,将最新的rails捕获到一个易于引用的位置:

cd ~/goodtimes

cd ~ /因着

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

git克隆https://github.com/rails/rails.git

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

我的路径包括一个~/桌面/Dropbox/所以我的代码随处可用。

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

然后参照rails exec构建一个新的应用:

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

~ /因着/ rails / bin / rails新培根——边缘

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:

我曾有一个问题部署到Heroku,但是theRubyRacer gem帮助解决了这个问题。下面是一个简单的Gem文件示例:

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.

我猜想将会有一些社区实用程序来帮助您自动地从旧版本的Rails迁移到边缘。

References:

引用:

  1. How to Play with Rails 3.1, CoffeeScript and All That Jazz Right Now
  2. 如何使用Rails 3.1、CoffeeScript以及所有这些
  3. The Four Horsemen of Rails 3.1beta, Coffee-Script, jQuery, SCSS and Assets
  4. Rails 3.1beta、Coffee-Script、jQuery、SCSS和Assets的四骑士
  5. Rails 3.1beta deployed to Heroku from your iPhone
  6. Rails 3.1beta从iPhone部署到Heroku
  7. Reversible Migrations
  8. 可逆迁移

#5


3  

I recommend updating your Gemfile to use edge rails. For example:

我建议更新Gemfile以使用edge rails。例如:

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.

您可以在这里阅读更多http://pogodan.com/blog/2011/04/24/easy-edge-rails。

#6


2  

http://railscasts.com/episodes/282-upgrading-to-rails-3-1

http://railscasts.com/episodes/282-upgrading-to-rails-3-1

this railscast might help !

这条铁路可能会有帮助!

#7


1  

If i understood your question correctly this is how:

如果我正确地理解了你的问题,这就是:

gem install rails --pre

#8


1  

This is a pretty good guide which goes into some detail about installing Rails 3.1:

这是一个非常好的指南,详细介绍了安装Rails 3.1的一些细节:

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

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

#9


0  

Upgrading a rails 3.0.7 and 3.0.9 app using this guide worked for me

使用本指南升级rails 3.0.7和3.0.9应用程序对我很有效

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

http://davidjrice.co.uk/2011/05/25/how - - - rails应用程序升级到版本- 3 - 1 - 0. html

You can skip steps 3 and higher if you want--it will still work, although you won't be taking advantage of everything new in rails 3.1.

如果愿意,您可以跳过步骤3或更高的步骤——它仍然可以工作,尽管您不会利用rails 3.1中的所有新功能。

#1


54  

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

这正是我在更新现有rails 3.0.8项目时所做的。你的情况可能不同……

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

更新在我的Gemfile中指定的rails版本,以使用最新的版本候选:

gem 'rails', '3.1.0.rc4’

Update the bundle:

更新包:

bundle update

Then update the project with the rake command:

然后使用rake命令更新项目:

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.

在选择了更改后,我运行了所有的测试,然后他们通过了(yay!)我重新启动了服务器,到目前为止一切看起来都很好。

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.

然而,这还没有使用新的资产管道。我的意思是,javascript和css(或sass)文件仍在以管道前的方式处理。据我所知,这是一个完全可行的选择。但是,当然,我想要新的好处,所以我相信接下来的步骤是包括和额外的宝石(例如coffeescript, sass, uglifier等),然后将旧文件迁移到app/assets目录。

I found some details about that are here:

我在这里找到了一些细节:

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

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

Hope that was helpful.

希望是有帮助的。

#2


28  

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

我刚刚将Gemfile更改为:

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/environment /development.rb中注释了下面一行

# config.action_view.debug_rjs = true

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

最后,确保在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

我不确定您是否已经阅读了发行说明http://weblog.rubyonrails.org/2011/4/21/jquery-new-default。

#3


24  

Upgrade to Rails 3.1

升级到Rails 3.1

watch it :)

看:)

#4


13  

Upgrading Rails

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

更新:小心使用系统rake,因为rake已经升级。

bundle exec rake

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

确保在给定的rails项目(源)中使用正确的rake


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

我建议从一个新的应用开始,然后复制你的特定应用信息,同时将你的资源转换成新的资产/ spro佝偻病格式。

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).

在将一个较旧的rails 2.3.4应用程序转换为3.0时,我在项目内一次修改一个文件时崩溃和烧毁。不用说,这是一个有缺陷的策略,但我确实在这方面学到了一点。最后我跳过了3.0,用一个新的应用程序切换到3.1beta1,在正确的迁移之后复制了我的应用程序和公共文件夹。这一举动有几个悬而未决的问题,最重要的是我没有使用rails edge来创建新的应用程序(感谢RubyInside的提示)。

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

首先,将最新的rails捕获到一个易于引用的位置:

cd ~/goodtimes

cd ~ /因着

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

git克隆https://github.com/rails/rails.git

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

我的路径包括一个~/桌面/Dropbox/所以我的代码随处可用。

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

然后参照rails exec构建一个新的应用:

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

~ /因着/ rails / bin / rails新培根——边缘

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:

我曾有一个问题部署到Heroku,但是theRubyRacer gem帮助解决了这个问题。下面是一个简单的Gem文件示例:

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.

我猜想将会有一些社区实用程序来帮助您自动地从旧版本的Rails迁移到边缘。

References:

引用:

  1. How to Play with Rails 3.1, CoffeeScript and All That Jazz Right Now
  2. 如何使用Rails 3.1、CoffeeScript以及所有这些
  3. The Four Horsemen of Rails 3.1beta, Coffee-Script, jQuery, SCSS and Assets
  4. Rails 3.1beta、Coffee-Script、jQuery、SCSS和Assets的四骑士
  5. Rails 3.1beta deployed to Heroku from your iPhone
  6. Rails 3.1beta从iPhone部署到Heroku
  7. Reversible Migrations
  8. 可逆迁移

#5


3  

I recommend updating your Gemfile to use edge rails. For example:

我建议更新Gemfile以使用edge rails。例如:

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.

您可以在这里阅读更多http://pogodan.com/blog/2011/04/24/easy-edge-rails。

#6


2  

http://railscasts.com/episodes/282-upgrading-to-rails-3-1

http://railscasts.com/episodes/282-upgrading-to-rails-3-1

this railscast might help !

这条铁路可能会有帮助!

#7


1  

If i understood your question correctly this is how:

如果我正确地理解了你的问题,这就是:

gem install rails --pre

#8


1  

This is a pretty good guide which goes into some detail about installing Rails 3.1:

这是一个非常好的指南,详细介绍了安装Rails 3.1的一些细节:

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

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

#9


0  

Upgrading a rails 3.0.7 and 3.0.9 app using this guide worked for me

使用本指南升级rails 3.0.7和3.0.9应用程序对我很有效

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

http://davidjrice.co.uk/2011/05/25/how - - - rails应用程序升级到版本- 3 - 1 - 0. html

You can skip steps 3 and higher if you want--it will still work, although you won't be taking advantage of everything new in rails 3.1.

如果愿意,您可以跳过步骤3或更高的步骤——它仍然可以工作,尽管您不会利用rails 3.1中的所有新功能。