Rails gemfile编辑

Sas*_*sha 2 bundle ruby-on-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'  
Run Code Online (Sandbox Code Playgroud)

当我尝试使用bundle install该文件时,bundle install --without production按照说明使用,我收到此错误:

You need to specify gem names as Strings. Use 'gem "development"' instead.
Run Code Online (Sandbox Code Playgroud)

当我返回文件和变更gem :developmentgem "development"我,而不是说:

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

我是新手,并且当一套明确的指令似乎与另一套明显冲突并且都不起作用时,我真的不知道该怎么做,特别是因为我并不真正理解这些术语的含义.

非常感谢帮助,

alf*_*alf 8

:development应该是一个群体,而不是一个宝石.试试这个:

group :development do
  gem 'sqlite3', '1.3.5'
end
Run Code Online (Sandbox Code Playgroud)

这意味着开发组内的所有gem都应该加载到开发环境中.在这种情况下,在生产或测试中运行时,您将没有sqlite gem.

这同样适用于生产组.

仅在为资产管道编译资产时才加载资产组.