gpt4 book ai didi

ruby-on-rails - Localhost :3000 claims "gem ' pg'"in not installed, Heroku 应用运行正常

转载 作者:行者123 更新时间:2023-11-29 13:00:04 25 4
gpt4 key购买 nike

我的 localhost:3000 给我这个错误:

Specified 'postgresql' for database adapter, but the gem is not loaded. Add gem 'pg' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

gem 已安装并已捆绑。让我感到困惑的是 Heroku 应用程序运行良好。当我尝试运行 rake db:create 时,我也遇到了同样的错误。

我目前正在参加学习 RoR 的类(class),我在社区论坛上问过这个问题,但没有成功。

我的 gemfile 是:

source 'https://rubygems.org'
ruby '2.2.1'


gem 'rails', '4.2.4'

gem 'sass-rails', '~> 5.0'

gem 'bootstrap-sass', '~> 3.3.5'

gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.1.0'

gem 'turbolinks'

gem 'jbuilder', '~> 2.0'

gem 'sdoc', '~> 0.4.0', group: :doc

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

group :production do

gem 'pg', '~>0.18.3'

gem 'rails_12factor'

end

group :development, :test do

gem 'byebug'

end

group :development do

gem 'spring'

end

我的 database.yml 是:

default: &default
adapter: postgresql
pool: 5
timeout: 5000

development:

<<: *default
adapter: postgresql
encoding: unicode
database: my_development
username: davideye
password: 1234
host: localhost
port: 5432


test:

<<: *default
database: my_test
username: davideye
password: 1234

production:

<<: *default
database: my_production
username: davideye
password: 1234

最佳答案

在 database.yml 中,您已经为开发定义了 postgres,而在 gemfile 中,您已经为开发定义了 sqlite3。所以要么改变你的 database.yml 要么在开发中的 gemfile 而不是 sqlite3pg.

关于ruby-on-rails - Localhost :3000 claims "gem ' pg'"in not installed, Heroku 应用运行正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32941277/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com