Ruby on rails 您的gem文件多次列出gem。可能会导致错误

Ruby on rails 您的gem文件多次列出gem。可能会导致错误,ruby-on-rails,ruby,postgresql,heroku,sqlite,Ruby On Rails,Ruby,Postgresql,Heroku,Sqlite,当我运行bundle install时,我当前收到以下消息 Your Gemfile lists the gem sqlite3 (= 1.3.5) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. Your Gemfi

当我运行bundle install时,我当前收到以下消息

Your Gemfile lists the gem sqlite3 (= 1.3.5) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem rspec-rails (= 2.10.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem rspec-rails (= 2.10.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem pg (= 0.12.2) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
我和Heroku一起使用Postgresql,我相信我在开发和测试中都在使用Postgresql。我最近从sqlite迁移/切换到postgresql

我在:开发还是在:开发,:测试中仍然需要sqlite3 gems?

最后,开发和测试之间有区别吗?

database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: xxxxxx_development
  pool: 5
  username: xxxxxx
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: xxxxxx_development
  pool: 5
  username: xxxxxx
  password:
Gemfile

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
  gem 'guard-rspec', '0.5.5'
end

group :development do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
end

# Test gems on Macintosh OS X
group :test do
  gem 'rspec-rails', '2.10.0'
end

group :production do
  gem 'pg', '0.12.2'
  gem 'rack-google_analytics'
end

您在此处重复将sqlite放入开发组:

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
  gem 'guard-rspec', '0.5.5'
end

group :development do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
end
您可以在这里删除您的第二个开发组列表,因为它没有添加任何内容—您已经在第一条语句中将它们放在了开发和测试中。类似地,将pg放在任何组之外,它在所有组中都是可用的,因此将其添加到生产中就是一个重复的列表

重写您的文件可能是:

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

# gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
end

group :test do
  gem 'guard-rspec', '0.5.5'
end

group :production do
  gem 'pg', '0.12.2'
  gem 'rack-google_analytics'
end
另外,有人提出了一个很友好的建议:试着在开发和生产中使用相同的db。我知道一开始在本地建立博士后可能会很棘手,但一旦建立起来,它就会坚如磐石,非常容易使用。由于PG和SQLite实现之间的差异(例如在字段iirc中搜索文本),您将面临更少的错误风险

没有sqlite时:

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
  gem 'rspec-rails', '2.10.0'
end

group :test do
  gem 'guard-rspec', '0.5.5'
end

group :production do
  gem 'rack-google_analytics'
end

如果您在所有环境中都使用pg,请删除sqlite3 gem


:development和:development,:test之间的区别在于:development,:test用于需要包含在这两个环境中的gem开发是为了:只开发gem。

如果在同一环境中有gem sqlite3、pg、respec rails,则需要删除同一gem的副本

按如下方式编辑gem文件:

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'


group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
  gem 'guard-rspec', '0.5.5'
end


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

所以在第一个声明中,我列出了开发和测试环境中的gem。我想是的,但我想确定一下。谢谢。:)我也可以提个建议吗?你可能想在本地安装Postgres进行开发,并在生产中使用与开发相同的db。从长远来看,痛苦要小得多。是的-如果您在本地使用postgres,并且已经设置好了它,那么您不需要sqlite。在进行上述更改之后,您是否运行了bundle安装?这是用于在本地安装bundle吗?您是否在生产中遇到了错误?您不需要在开发组中使用
guard rspec