2011-05-11 252 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