我仍然是Ruby on Rails的相對新手,而且我是Heroku的完全新手。Heroku在我的Rails應用程序中不會識別'pg'寶石Gemfile
我已經在開發和生產環境中設置了我的Rails應用程序,以使用postgres而不是sqlite3,並且已將「gem'pg'」放入我的Gemfile中。而在本地,我的應用程序工作得很好。
使它在Heroku上工作是一個不同的故事。在我將應用程序推送到Heroku後,當我輸入「heroku run rake db:migrate」時,它告訴我:「rake aborted!爲數據庫適配器指定了'postgresql',但該gem未加載。的Gemfile「。
是的,gem 'pg'
是在我的Gemfile中,但我仍然收到此錯誤。
什麼給?
這裏是我的Gemfile看起來像現在:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.1'
gem 'pg'
group :assets do
end
gem 'bcrypt-ruby', '~> 3.1.2'
gem 'haml'
gem 'devise', '3.0.0.rc'
gem 'protected_attributes'
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'knockout-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'unicorn'
gem 'rails_12factor', '0.0.2'
end
這裏就是我的database.yml是這樣的:
development:
adapter: postgresql
encoding: unicode
database: financemeter
pool: 5
password:
test:
adapter: postgresql
encoding: unicode
database: financemeter
pool: 5
timeout: 5000
production:
adapter: postgresql
database: dbe67fgdnnqg88
pool: 5
timeout: 5000
user: njatxlpjjrzfoe
password: HULxOtPALAk4FnzZe-_737TvPc
這裏是完整的錯誤日誌,當我嘗試遷移在Heroku 。 (同樣,在當地我很好。我在本地在MacBook上,如果該事項的工作。)
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/connection_specification.rb:32:in `spec'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_handling.rb:39:in `establish_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/lazy_load_hooks.rb:27:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/railtie.rb:174:in `block in <class:Railtie>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/application.rb:215:in `initialize!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/application.rb:189:in `require_environment!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/application.rb:250:in `block in run_tasks_blocks'
確保做一個捆綁安裝的用戶名和主機之後提交你的Gemfile和Gemfile.lock。嘗試部署然後 – lsaffie
我試過了 - 它沒有幫助。我不知道是不是因爲Heroku沒有更新 - 當我做「git push heroku master」時,它會返回一個簡單的「一切都是最新的」消息,而不會告訴我我的更改已被推送。 – drumwolf
你知道你在你的gemfile中有兩次'pg'gem嗎?嘗試從':production'組中刪除它,然後運行'bundle update','bundle install'並嘗試推送它。 – Tim