2012-05-26 94 views
2

我開始一個Rails教程,告訴我編輯Gemfile中創建一個新的演示應用程序時:的Rails的Gemfile編輯

source 'https://rubygems.org' 

gem 'rails', '3.2.3' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

gem :development do 
gem 'sqlite3', '1.3.5' 
end 


# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '3.2.4' 
    gem 'coffee-rails', '3.2.2' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platform => :ruby 

    gem 'uglifier', '1.2.3' 
end 

gem 'jquery-rails', '2.0.0' 

group :production do 
    gem 'pg', '0.12.2' 
end 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# To use Jbuilder templates for JSON 
# gem 'jbuilder' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug19', :require => 'ruby-debug' 

當我嘗試bundle install文件,使用bundle install --without production,按照指示,我得到這個錯誤:

You need to specify gem names as Strings. Use 'gem "development"' instead. 

當我回到文件並更改gem :developmentgem "development"我不是告訴:

Could not find gem 'development (>= 0) ruby' in the gems available on this machine. 

我對此很陌生,當一套明確的指示似乎與另一套指令衝突並且都不起作用時,我真的不知道該怎麼辦,特別是因爲我不太瞭解這些術語的含義。

幫助將是非常讚賞,

回答

8

:development應該是一個羣體,而不是一個寶石。試試這個:

group :development do 
    gem 'sqlite3', '1.3.5' 
end 

這意味着開發組內的所有gem都應該加載到開發環境中。在這種情況下,您在生產或測試中運行時不會有sqlite gem。

這同樣適用於生產組。

資產組僅在編譯Asset Pipeline的資產時加載。

+1

哦。真棒。我是一個白癡,沒有看到這一點。非常感謝SOOO(對於解釋)。 – Sasha