部署到Heroku时Heroku应用程序错误

时间:2018-03-16 06:34:20

标签: ruby-on-rails heroku

几天前我开始使用“rails tutorial”开始在rails上学习ruby,我已经遇到了下面的错误。

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.

尝试部署应用时出现此错误:

ec2-user:~/environment/hello_app (master) $ heroku create
ec2-user:~/environment/hello_app (master) $ git push heroku master
Counting objects: 1, done.
Writing objects: 100% (1/1), 211 bytes | 211.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 1.15.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        Fetching gem metadata from https://rubygems.org/.........
remote:        Fetching version metadata from https://rubygems.org/..
remote:        Fetching dependency metadata from https://rubygems.org/.
remote:        Using rake 12.3.0
remote:        Using concurrent-ruby 1.0.5
remote:        Using minitest 5.11.3
remote:        Using thread_safe 0.3.6
remote:        Using builder 3.2.3
remote:        Using erubi 1.7.1
remote:        Using mini_portile2 2.3.0
remote:        Using crass 1.0.3
remote:        Using rack 2.0.4
remote:        Using nio4r 2.2.0
remote:        Using websocket-extensions 0.1.3
remote:        Using mini_mime 1.0.0
remote:        Using arel 8.0.0
remote:        Using bundler 1.15.2
remote:        Using coffee-script-source 1.12.2
remote:        Using execjs 2.7.0
remote:        Using method_source 0.9.0
remote:        Using thor 0.20.0
remote:        Using ffi 1.9.23
remote:        Using multi_json 1.13.1
remote:        Using puma 3.9.1
remote:        Using rb-fsevent 0.10.3
remote:        Using tilt 2.0.8
remote:        Using turbolinks-source 5.1.0
remote:        Using tzinfo 1.2.5
remote:        Using nokogiri 1.8.2
remote:        Using i18n 0.9.5
remote:        Using rack-test 0.8.3
remote:        Using sprockets 3.7.1
remote:        Using websocket-driver 0.6.5
remote:        Using mail 2.7.0
remote:        Using coffee-script 2.4.1
remote:        Using uglifier 3.2.0
remote:        Using rb-inotify 0.9.10
remote:        Using turbolinks 5.0.1
remote:        Using loofah 2.2.0
remote:        Using activesupport 5.1.4
remote:        Using sass-listen 4.0.0
remote:        Using rails-html-sanitizer 1.0.3
remote:        Using sass 3.5.5
remote:        Using rails-dom-testing 2.0.3
remote:        Using globalid 0.4.1
remote:        Using activemodel 5.1.4
remote:        Using jbuilder 2.6.4
remote:        Using actionview 5.1.4
remote:        Using activejob 5.1.4
remote:        Using activerecord 5.1.4
remote:        Using actionpack 5.1.4
remote:        Using actioncable 5.1.4
remote:        Using actionmailer 5.1.4
remote:        Using railties 5.1.4
remote:        Using sprockets-rails 3.2.1
remote:        Using coffee-rails 4.2.2
remote:        Using jquery-rails 4.3.1
remote:        Using rails 5.1.4
remote:        Using sass-rails 5.0.6
remote:        Bundle complete! 15 Gemfile dependencies, 56 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Bundle completed (3.14s)
remote:        Cleaning up the bundler cache.
remote:        Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        The latest bundler is 1.16.1, but you are currently running 1.15.2.
remote:        To update, run `gem install bundler`
remote: -----> Installing node-v6.11.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        Asset precompilation completed (1.65s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote: 
remote: ###### WARNING:
remote:        You have not declared a Ruby version in your Gemfile.
remote:        To set your Ruby version add this line to your Gemfile:
remote:        ruby '2.3.4'
remote:        # See https://devcenter.heroku.com/articles/ruby-versions for more information.
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> web
remote:        Default types for buildpack -> console, rake, worker
remote: 
remote: -----> Compressing...
remote:        Done: 35.8M
remote: -----> Launching...
remote:        Released v9
remote:        https://obscure-lake-54868.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/obscure-lake-54868.git
   37e8a0c..97c59d3  master -> master

我将行ruby '2.3.4'添加到Gemfile,但此警告仍然不会消失。正如这个错误所说,我跑heroku logs,但我不知道如何解决这个问题。以下是heroku logs的结果。对不起,超长。

ec2-user:~/environment/hello_app (master) $ heroku logs
2018-03-16T05:35:32.900603+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
2018-03-16T05:35:32.900608+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
2018-03-16T05:35:32.900610+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-03-16T05:35:32.900612+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-03-16T05:35:32.912746+00:00 app[web.1]: => Booting Puma
2018-03-16T05:35:32.912753+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-03-16T05:35:32.912755+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-03-16T05:35:32.912756+00:00 app[web.1]: Exiting
2018-03-16T05:35:33.004749+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-16T05:35:33.006915+00:00 heroku[web.1]: State changed from crashed to starting
2018-03-16T05:35:32.972692+00:00 heroku[web.1]: Process exited with status 1
2018-03-16T05:35:36.687462+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 4593 -e production`
2018-03-16T05:35:41.293329+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-16T05:35:41.279319+00:00 heroku[web.1]: Process exited with status 1
2018-03-16T05:35:41.177337+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
2018-03-16T05:35:41.177313+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
2018-03-16T05:35:41.177352+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
2018-03-16T05:35:41.177354+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:58:in `establish_connection'
2018-03-16T05:35:41.177360+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
2018-03-16T05:35:41.177362+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
2018-03-16T05:35:41.177364+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
2018-03-16T05:35:41.177365+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
2018-03-16T05:35:41.177366+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
2018-03-16T05:35:41.177368+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
2018-03-16T05:35:41.177370+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
2018-03-16T05:35:41.177371+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
2018-03-16T05:35:41.177373+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
2018-03-16T05:35:41.177374+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
2018-03-16T05:35:41.177376+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
2018-03-16T05:35:41.177378+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
2018-03-16T05:35:41.177379+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
2018-03-16T05:35:41.177381+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
2018-03-16T05:35:41.177382+00:00 app[web.1]:    from /app/app/models/application_record.rb:1:in `<top (required)>'
2018-03-16T05:35:41.177387+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
2018-03-16T05:35:41.177388+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
2018-03-16T05:35:41.177390+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
2018-03-16T05:35:41.177391+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
2018-03-16T05:35:41.177393+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:379:in `block in require_or_load'
2018-03-16T05:35:41.177394+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:36:in `block in load_interlock'
2018-03-16T05:35:41.177396+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
2018-03-16T05:35:41.177398+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
2018-03-16T05:35:41.177399+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:11:in `loading'
2018-03-16T05:35:41.177404+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:36:in `load_interlock'
2018-03-16T05:35:41.177405+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:357:in `require_or_load'
2018-03-16T05:35:41.177407+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:335:in `depend_on'
2018-03-16T05:35:41.177408+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:251:in `require_dependency'
2018-03-16T05:35:41.177410+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
2018-03-16T05:35:41.177412+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:475:in `each'
2018-03-16T05:35:41.177416+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:475:in `block in eager_load!'
2018-03-16T05:35:41.177418+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:473:in `each'
2018-03-16T05:35:41.177420+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:473:in `eager_load!'
2018-03-16T05:35:41.177421+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:354:in `eager_load!'
2018-03-16T05:35:41.177423+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:67:in `each'
2018-03-16T05:35:41.177428+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>'
2018-03-16T05:35:41.177429+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
2018-03-16T05:35:41.177431+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
2018-03-16T05:35:41.177432+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
2018-03-16T05:35:41.177436+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
2018-03-16T05:35:41.177474+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2018-03-16T05:35:41.177526+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
2018-03-16T05:35:41.177502+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
2018-03-16T05:35:41.177550+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each'
2018-03-16T05:35:41.177575+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call'
2018-03-16T05:35:41.177599+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
2018-03-16T05:35:41.177623+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
2018-03-16T05:35:41.177646+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
2018-03-16T05:35:41.177673+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
2018-03-16T05:35:41.177720+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
2018-03-16T05:35:41.177748+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2018-03-16T05:35:41.177773+00:00 app[web.1]:    from config.ru:3:in `require_relative'
2018-03-16T05:35:41.177798+00:00 app[web.1]:    from config.ru:3:in `block in <main>'
2018-03-16T05:35:41.177822+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `instance_eval'
2018-03-16T05:35:41.177846+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `initialize'
2018-03-16T05:35:41.177871+00:00 app[web.1]:    from config.ru:in `new'
2018-03-16T05:35:41.177896+00:00 app[web.1]:    from config.ru:in `<main>'
2018-03-16T05:35:41.177920+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `eval'
2018-03-16T05:35:41.177944+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `new_from_string'
2018-03-16T05:35:41.177968+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in `parse_file'
2018-03-16T05:35:41.177992+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2018-03-16T05:35:41.178019+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/server.rb:219:in `app'
2018-03-16T05:35:41.178045+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:24:in `app'
2018-03-16T05:35:41.178071+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/server.rb:354:in `wrapped_app'
2018-03-16T05:35:41.178096+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.4/lib/rack/server.rb:283:in `start'
2018-03-16T05:35:41.178121+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:44:in `start'
2018-03-16T05:35:41.178152+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:135:in `block in perform'
2018-03-16T05:35:41.178177+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
2018-03-16T05:35:41.178199+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
2018-03-16T05:35:41.178247+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
2018-03-16T05:35:41.178223+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
2018-03-16T05:35:41.178272+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
2018-03-16T05:35:41.178295+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-03-16T05:35:41.178319+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
2018-03-16T05:35:41.178341+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
2018-03-16T05:35:41.178363+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-03-16T05:35:41.178388+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-03-16T05:35:41.196457+00:00 app[web.1]: => Booting Puma
2018-03-16T05:35:41.196462+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-03-16T05:35:41.196464+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-03-16T05:35:41.196466+00:00 app[web.1]: Exiting
2018-03-16T05:35:42.194333+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-lake-54868.herokuapp.com request_id=5db8303d-ff52-4273-a347-a73b46ef1d72 fwd="115.165.98.19" dyno= connect= service= status=503 bytes= protocol=https
2018-03-16T05:35:42.900389+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-lake-54868.herokuapp.com request_id=37e231a2-72ce-45da-95a3-0f0301c50abd fwd="115.165.98.19" dyno= connect= service= status=503 bytes= protocol=https

访问其他网站后,我尝试$ heroku ps:restart web.1,但错误并未消失。任何人都可以帮我吗? 我不擅长英语,请原谅我一些语法错误。

*下面是我的Gemfile

source 'https://rubygems.org'
ruby "2.3.4"

gem 'rails',        '5.1.4'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.6.4'

group :development, :test do
  gem 'sqlite3',      '1.3.13'
  gem 'byebug', '9.0.6', platform: :mri
end

group :development do
  gem 'web-console',           '3.5.1'
  gem 'listen',                '3.1.5'
  gem 'spring',                '2.0.2'
  gem 'spring-watcher-listen', '2.0.1'
end

group :production do
  gem 'pg', '~> 0.20.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

1 个答案:

答案 0 :(得分:1)

因为您必须在全局范围内sqlite3 Gemfile,所以您需要为开发指定数据库gem&amp;单独制作,就像你的Gemfile

一样

小组制作

group :production do
  gem 'pg', '~> 0.11'
  #Or
  #gem 'pg', '~> 0.20.0'
end 

注意: >之前的波形符号,这不是短划线

小组测试&amp;发展

group :test, :development do
    gem 'sqlite3'
end 

然后bundle install --without production(更新Gemfile.lock文件)执行git add / commit循环,然后重新部署到Heroku。

然后heroku run rake db:setupheroku run rake db:createheroku run rake db:migrate

<强>更新

生产区块上的

database.yml

示例结构

production:
  <<: *default
  database: project_name_production
  username: project_name
  password: <%= ENV['PROJECT_NAME_DATABASE_PASSWORD'] %>

在使用Heroku

创建rails项目时,默认情况下会创建此结构