【问题标题】:Rails gemfile editingRails gem 文件编辑
【发布时间】:2012-05-26 00:01:38
【问题描述】:

我正在开始一个 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 --without production 尝试bundle install 文件时,我收到此错误:

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

当我返回文件并将 gem :development 更改为 gem "development" 时,我被告知:

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

我是新手,当一组明确的说明似乎与另一组发生冲突并且两者都不起作用时,我真的不知道该怎么办,特别是因为我并不真正理解这些术语中的任何一个是什么意思。

非常感谢您的帮助,

【问题讨论】:

    标签: ruby-on-rails bundle gemfile


    【解决方案1】:

    :development 应该是一个组,而不是一个 gem。试试这个:

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

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

    同样适用于生产组。

    仅在编译 Asset Pipeline 的资产时加载资产组。

    【讨论】:

    • 哦。惊人的。我是个白痴,因为没有看到。非常感谢(也为解释)。
    猜你喜欢
    • 2014-03-20
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 2010-09-06
    • 1970-01-01
    • 1970-01-01
    • 2013-03-06
    • 2013-05-24
    相关资源
    最近更新 更多