我对rails很新。我正在尝试遵循Michael Hartl的Rails教程,我遇到了部署到Heroku的问题。我成功地部署了一次,但是现在我已经完成了另一个部分,我再次部署时遇到了问题。我已经包含了我的终端输入和结果,我的database.yml和我的Gemfile。在此先感谢您的帮助!
sample_app: (master)$ git push heroku master
Fetching repository, done.
Counting objects: 58, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (40/40), done.
Writing objects: 100% (42/42), 5.95 KiB | 0 bytes/s, done.
Total 42 (delta 13), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.2
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Using rake 10.3.2
Using minitest 5.4.2
Using i18n 0.7.0.beta1
Using thread_safe 0.3.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.0
Using rack 1.6.0.beta
Using mime-types 2.4.1
Using arel 6.0.0.beta1
Using bcrypt 3.1.7
Using sass 3.4.5
Using will_paginate 3.0.7
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using thor 0.19.1
Using excon 0.40.0
Using json 1.8.1
Using formatador 0.2.5
Using net-ssh 2.9.1
Using multi_json 1.10.1
Using inflecto 0.0.2
Using ipaddress 0.8.0
Using subexec 0.2.3
Using hike 1.2.3
Using bundler 1.6.3
Using tilt 1.4.1
Using tzinfo 1.2.2
Using faker 1.4.2
Using nokogiri 1.6.3.1
Using mail 2.6.1
Using rack-test 0.6.2
Using bootstrap-will_paginate 0.0.10
Using coffee-script 2.3.0
Using net-scp 1.2.1
Using bootstrap-sass 3.2.0.0
Using fog-json 1.0.0
Using mini_magick 3.8.0
Using sprockets 2.12.2
Using activesupport 4.2.0.beta2
Using rdoc 4.1.2
Using uglifier 2.5.3
Using fog-core 1.24.0
Using globalid 0.3.0
Using activemodel 4.2.0.beta2
Using jbuilder 2.1.3
Using loofah 2.0.1
Using fog-brightbox 0.5.1
Using fog-softlayer 0.3.20
Using activejob 4.2.0.beta2
Using sdoc 0.4.0
Using activerecord 4.2.0.beta2
Using rails-deprecated_sanitizer 1.0.3
Using rails-html-sanitizer 1.0.1
Using fog 1.23.0
Using rails-dom-testing 1.0.3
Using carrierwave 0.10.0
Using actionview 4.2.0.beta2
Using actionpack 4.2.0.beta2
Using actionmailer 4.2.0.beta2
Using sprockets-rails 3.0.0.beta1
Using railties 4.2.0.beta2
Using coffee-rails 4.0.1
Using sass-rails 5.0.0.beta1
Using turbolinks 2.3.0
Using jquery-rails 3.1.2
Using rails 4.2.0.beta2
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (0.83s)
Cleaning up the bundler cache.
Removing rails_12factor (0.0.2)
Removing pg (0.17.1)
Removing raindrops (0.13.0)
Removing rails_stdout_logging (0.0.3)
Removing unicorn (4.8.3)
Removing rails_serve_static_assets (0.0.2)
Removing kgio (2.9.2)
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/connection_specification.rb:173:in `spec'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_handling.rb:50:in `establish_connection'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:27:in `each'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:30:in `run'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:349:in `initialize!'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/config/environment.rb:5:in `<top (required)>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:325:in `require_environment!'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:438:in `block in run_tasks_blocks'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-3.0.0.beta1/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Gem::LoadError: pg is not part of the bundle. Add it to Gemfile.
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/bundler-1.6.3/lib/bundler/rubygems_integration.rb:252:in `block in replace_gem'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/postgresql_adapter.rb:16:in `<top (required)>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/connection_handling.rb:50:in `establish_connection'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:27:in `each'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.0.beta2/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:30:in `run'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:349:in `initialize!'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/config/environment.rb:5:in `<top (required)>'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:325:in `require_environment!'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0.beta2/lib/rails/application.rb:438:in `block in run_tasks_blocks'
/tmp/build_a852f630-86fd-4560-a8ec-95e7343a25ee/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-3.0.0.beta1/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
To git@heroku.com:someapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:someapp.git'
Gemfile
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.2.0.beta2'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.23.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.0.beta1'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.1.2'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.1.3'
gem 'rails-html-sanitizer', '1.0.1'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'unicorn', '4.8.3'
end
的database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
答案 0 :(得分:1)
首先更改您的database.yml。从生产开始,你使用的是postgres,你需要在database.yml中提到它。
在生产区块中
production:
adapter: postgresql
encoding: unicode
database: database_name
再次捆绑安装并将gemfile和gemfile.lock推送到heroku