簡體   English   中英

在推送到heroku之前,預編譯Rails上的postgresql錯誤

[英]postgresql error on rails precompile prior to push to heroku

上在線學習Rails的課程。 我運行以下命令-

設置RAILS_ENV =生產

捆綁執行耙資產:預編譯

這是我得到的錯誤-

耙子流產了! ActiveRecord :: AdapterNotSpecified:未配置'postgresql'數據庫。 可用的:[“默認”,“開發”,“測試”,“生產”,“適配器”,“數據庫”,“編碼”,“ min_messages”,“池”,“超時”] C:/用戶/用戶名/work/stukdo/config/environment.rb:5:in`'任務:TOP =>環境(通過使用--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之前對其進行預編譯。

文件應如下所示:

的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

您必須將最后的代碼塊移到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'] %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM