2015-07-10 15 views
0

請幫忙解決問題。如何在配置中指定數據庫?

我做了一個網站。我使用sqlite3。 的database.yml:

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

development: 
    <<: *default 
    database: db/development.sqlite3 

test: 
    <<: *default 
    database: db/test.sqlite3 

production: 
    <<: *default 
    database: db/production.sqlite3 

的Gemfile:

source 'https://rubygems.org' 

gem 'rails', '4.2.1' 
gem 'sass-rails', '~> 5.0' 
gem 'uglifier', '>= 1.3.0' 
gem 'coffee-rails', '~> 4.1.0' 
gem 'jquery-rails' 
gem 'turbolinks' 
gem 'jbuilder', '~> 2.0' 
gem 'sdoc', '~> 0.4.0', group: :doc 
gem 'bootstrap-sass', '3.2.0.0' 
gem 'bcrypt', '~> 3.1.7' 
gem 'populate' 
gem 'faker' 
gem 'russian', '~> 0.6.0' 
gem 'will_paginate' 
gem 'paperclip' 
gem 'fancybox2-rails', '~> 0.2.8' 
gem 'rspec-rails' 
gem 'factory_girl' 
gem 'database_cleaner' 

group :development do 
    gem 'sqlite3' 
end 

group :production do 
    gem 'pg' 
    gem 'rails_12factor' 
end 

group :development, :test do 
    gem 'byebug' 
    gem 'web-console', '~> 2.0' 
    gem 'spring' 
end 

它運行在本地服務器上。我把它上傳到heroku。作爲得到以下錯誤消息的結果:

500內部服務器錯誤

heroku上使用的PostgreSQL。那就是問題所在。請幫助設置配置

+0

請在發佈前做一些基礎研究問題,並讓我們知道你的嘗試。 – wrtsprt

回答

0

正如它所說:您需要添加pg寶石。包括下面一行在你的Gemfile

gem 'pg', group: :production 

,你們便在的config/database.yml的文件,你可以寫適當修改下面的代碼:

development: 
    adapter: postgresql 
    encoding: unicode 
    database: myapp_development 
    pool: 5 
    username: myapp 
    password: password1 

test: 
    adapter: postgresql 
    encoding: unicode 
    database: myapp_test 
    pool: 5 
    username: myapp 
    password: password1 

production: 
    adapter: postgresql 
    encoding: unicode 
    database: myapp_prouduction 
    pool: 5 
    username: myapp 
    password: password1 
相關問題