在推送到 heroku 之前,rails 预编译出现 postgresql 错误
postgresql error on rails precompile prior to push to heroku
在线学习课程Rails。
我 运行 以下命令 --
set RAILS_ENV=production
bundle exec rake assets:precompile
这是我得到的错误 --
rake aborted! ActiveRecord::AdapterNotSpecified: 'postgresql' database is not configured. Avai lable: ["default", "development",
"test", "production", "adapter", "database", " encoding",
"min_messages", "pool", "timeout"]
C:/Users/username/work/stukdo/config/environment.rb:5:in `' Tasks: TOP => environment (See full trace by running task
with --trace
我的 gemfile 有以下内容:
group :development, :test do
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
...这是我的 database.yml 文件:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production: &default
adapter: postgresql
database: todoism
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
有什么想法吗?我正在严格按照课程进行。我试图在将这些文件上传到 heroku 之前对其进行预编译。
您必须移动 database.yml 文件中的最后一段代码:
production:
adapter: postgresql
database: todoism
encoding: utf8
pool: 5
timeout: 5000
username: YOUR USERNAME
password: <%= ENV['THE DATABASE PASSWORD YOU CONFIGURED ON HEROKU'] %>
文件应如下所示:
gemfile
source 'https://rubygems.org'
group :development, :test do
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
/config/database.yml
development:
adapter: postgresql
host: localhost
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options
test:
adapter: postgresql
host: 127.0.0.1
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options
production:
adapter: postgresql
host: 127.0.0.1
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options
在线学习课程Rails。 我 运行 以下命令 --
set RAILS_ENV=production
bundle exec rake assets:precompile
这是我得到的错误 --
rake aborted! ActiveRecord::AdapterNotSpecified: 'postgresql' database is not configured. Avai lable: ["default", "development", "test", "production", "adapter", "database", " encoding", "min_messages", "pool", "timeout"] C:/Users/username/work/stukdo/config/environment.rb:5:in `' Tasks: TOP => environment (See full trace by running task with --trace
我的 gemfile 有以下内容:
group :development, :test do
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
...这是我的 database.yml 文件:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production: &default
adapter: postgresql
database: todoism
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
有什么想法吗?我正在严格按照课程进行。我试图在将这些文件上传到 heroku 之前对其进行预编译。
您必须移动 database.yml 文件中的最后一段代码:
production:
adapter: postgresql
database: todoism
encoding: utf8
pool: 5
timeout: 5000
username: YOUR USERNAME
password: <%= ENV['THE DATABASE PASSWORD YOU CONFIGURED ON HEROKU'] %>
文件应如下所示:
gemfile
source 'https://rubygems.org'
group :development, :test do
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
/config/database.yml
development:
adapter: postgresql
host: localhost
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options
test:
adapter: postgresql
host: 127.0.0.1
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options
production:
adapter: postgresql
host: 127.0.0.1
encoding: utf8
database: todoism
pool: 5
username: <%= ENV['PG_USERNAME'] %>
password: <%= ENV['PG_PASSWORD'] %>
template: template0
# others options