哇我一直被困在這一天上。我在連接到Heroku上的database.yml時遇到問題。我在雪松和紅寶石1.9.2。我的開發和測試數據庫是sqlite3和prod數據庫是postgreSQL應付雪松規則。 這裏是我的Ruby腳本代碼:Heroku上的數據庫連接
Rails.env.production? ? (env = "production") : (env = "development")
dbconfig = YAML::load(File.open('config/database.yml'))[env]
ActiveRecord::Base.establish_connection(dbconfig)
一切順利的地方,但是當我推到Heroku的,我得到:
ArgumentError: syntax error on line 17, col 0: `adapter = uri.scheme'
from /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load'
它看起來像Heroku的不喜歡我的數據庫。陽明海運。下面是一個概述:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
encoding: unicode
database: foo
port: 5432
host: foobar.amazonaws.com
username: foo
password: bar
你有沒有設法連接到數據庫?答案似乎並不包含完整的連接解決方案。 – baash05