2011-05-11 153 views
61

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

+0

http://everydayrails.com/2011/05/08/rails-3.1-beta-rvm.html – 2011-05-11 17:26:30

+0

我在@ user730569下面给出了一些例子。我正在将rails 2.3.4应用程序迁移到3.1 beta版 – 2011-05-17 21:57:52

+0

刚刚将我的应用程序从3更新到3.1 - 记录它[这里](http://webtempest.com/upgrade-rails-3-to-3-1/) – Plattsy 2011-09-06 04:33:39

回答

1

如果我理解你的问题正确,这是多么:

gem install rails --pre 
24
+0

会覆盖旧的rails项目吗? – user730569 2011-05-11 17:53:46

+0

我认为你不能更新旧的项目,你应该生成新的项目 – bor1s 2011-05-11 18:30:45

+1

Railscasts是获得关于Rails信息的最佳站点之一,感谢Ryan Bates! – bor1s 2011-05-11 18:44:10

3

我建议您更新Gemfile中使用边缘轨道。例如:

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' 

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

+0

你的链接缺少一个0.应该是:http://pogodan.com/blog/2011/04/24/easy-edge-rails – 2011-06-03 23:46:46

13

升级的Rails

更新:谨慎使用系统耙,耙作为已经升级。

bundle exec rake 

确保你使用正确耙对于给定轨项目(source


我建议用新的应用开始,然后在您的应用程序特定信息的复制,而换挡你的资源转换为新的资产/链轮格式。

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

根据你的数据库的复杂性,你要么想用改变语法来创建新的迁移或离开他们是:

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

     t.timestamps 
     end 
    end 
    end 

我不得不部署到Heroku的一个问题,但theRubyRacer宝石帮助消除了这一点。这里有一个简单的宝石文件的例子:

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 

我怀疑会有社区工具来帮助您从到--edge旧版本的Rails的自动迁移。

参考文献:

  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
28

我刚刚从3.0改变我的Gemfile以升级到3.1:

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

我也是在配置/环境/ development.rb注释掉以下行下方

# config.action_view.debug_rjs = true 

最后,确保你能够在配置/应用程序资产的管道。RB

config.assets.enabled = true 

我不知道,如果您已经阅读发行说明http://weblog.rubyonrails.org/2011/4/21/jquery-new-default

+1

那是唯一真正回答的人。 railscasts插曲很棒,但没有说明如何迁移。 – 2011-05-31 22:05:03

+3

我会注意到'rc5'的Gemfile看起来有些不同;它会安装'sass-rails'和'coffee-rails',两个版本都是'3.1.0.rc1',并将这些宝石(和'uglifier'一起)放在一个“group:assets do/end'块中。它有助于在另一个目录中生成一个新的边缘Rails站点,以查看它添加的内容。 – 2011-07-29 15:57:05

54

这是更新现有的轨道3.0.8项目时什么为我工作。你的情况可能会有所不同...

更新我的Gemfile中指定的轨道版本使用最新发布候选:

gem 'rails', '3.1.0.rc4’ 

更新包:

bundle update 

然后更新与项目耙子命令:

rake rails:update 

虽然樱桃采摘虽然变化冲突我跑了我的测试,他们通过(耶!)。我重新启动了服务器,目前为止一切都很顺利。

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

我发现有关的一些细节在这里:

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

希望这是有帮助的。

+5

如果您只想更新包中的导轨特定宝石,您可以执行“捆绑更新导轨”。 – 2011-07-26 21:47:08

+0

工作就像一个魅力!但是,启用资产时,出现以下错误:'没有路由匹配[GET]/assets/application.css' – 2011-08-31 22:50:38