Ruby on Rails教程Heroku部署问题

Ruby on Rails Tutorial Heroku Deployment Issue

我已经开始了Ruby on Rails教程,在这里找到:

https://www.railstutorial.org/book/beging sec部署

我正在使用Cloud9在线IDE并尝试在Heroku上部署我的Hello World应用程序,但当我尝试打开该应用程序时,收到以下错误:

An error occurred in the application and your page could not be
served. Please try again in a few moments.If you are the application
owner, check your logs for details.

根据日志显示,Postgres PG GEM似乎有问题。这是GemFile:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
source 'https://rubygems.org'

gem 'rails',        '4.2.2'
gem 'sass-rails',   '5.0.2'
gem 'uglifier',     '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks',   '2.3.0'
gem 'jbuilder',    '2.2.3'
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 :production do  
gem 'pg',             '0.17.1'  
gem 'rails_12factor', '0.0.2'
end

为了准备将系统部署到生产环境中,我们运行带有特殊标志的bundle install,以防止本地安装任何生产gems(在这种情况下,它由pg和rails factor组成):

1
$ bundle install --without production

根据本教程,这是为了用pg和rails factor gems更新gemfile.lock。但是,这是gemfile.lock:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.2)
      actionpack (= 4.2.2)
      actionview (= 4.2.2)
      activejob (= 4.2.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.2)
      actionview (= 4.2.2)
      activesupport (= 4.2.2)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.2)
      activesupport (= 4.2.2)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.2)
      activesupport (= 4.2.2)
      globalid (>= 0.3.0)
    activemodel (4.2.2)
      activesupport (= 4.2.2)
      builder (~> 3.1)
    activerecord (4.2.2)
      activemodel (= 4.2.2)
      activesupport (= 4.2.2)
      arel (~> 6.0)
    activesupport (4.2.2)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arel (6.0.3)
    binding_of_caller (0.7.3.pre1)
      debug_inspector (>= 0.0.1)
    builder (3.2.2)
    byebug (3.4.0)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.9.1.1)
    columnize (0.9.0)
    debug_inspector (0.0.2)
    debugger-linecache (1.2.0)
    erubis (2.7.0)
    execjs (2.6.0)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    i18n (0.7.0)
    jbuilder (2.2.3)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.6.2)
    mini_portile (0.6.2)
    minitest (5.8.0)
    multi_json (1.11.2)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.2)
      actionmailer (= 4.2.2)
      actionpack (= 4.2.2)
      actionview (= 4.2.2)
      activejob (= 4.2.2)
      activemodel (= 4.2.2)
      activerecord (= 4.2.2)
      activesupport (= 4.2.2)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.2)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.2)
      loofah (~> 2.0)
    railties (4.2.2)
      actionpack (= 4.2.2)
      activesupport (= 4.2.2)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rdoc (4.2.0)
    sass (3.4.18)
    sass-rails (5.0.2)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.0)
      json (~> 1.8)
      rdoc (~> 4.0, < 5.0)
    slop (3.6.0)
    spring (1.1.3)
    sprockets (3.3.4)
      rack (~> 1.0)
    sprockets-rails (2.3.3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    sqlite3 (1.3.9)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (1.4.1)
    turbolinks (2.3.0)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.5.3)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.0.0.beta3)
      activemodel (~> 4.0)
      binding_of_caller (= 0.7.3.pre1)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
  ruby

DEPENDENCIES
  byebug (= 3.4.0)
  coffee-rails (= 4.1.0)
  jbuilder (= 2.2.3)
  jquery-rails (= 4.0.3)
  rails (= 4.2.2)
  sass-rails (= 5.0.2)
  sdoc (= 0.4.0)
  spring (= 1.1.3)
  sqlite3 (= 1.3.9)
  turbolinks (= 2.3.0)
  uglifier (= 2.5.3)
  web-console (= 2.0.0.beta3)

bundle是否应该将pg添加到gemfile.lock中?

该应用程序在云IDE上的Rails服务器上运行良好。以下是完整的日志,因为它有助于:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
2015-09-22T16:24:37.291738+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
2015-09-22T16:24:37.291740+00:00 app[web.1]:    from /app/config/environment.rb:5:in `
<top (required)>'
2015-09-22T16:24:37.291743+00:00 app[web.1]:    from /app/config.ru:3:in `require'

2015-09-22T16:24:37.291753+00:00 app[web.1]:    from /app/config.ru:in `new'
2015-09-22T16:24:37.291748+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `
instance_eval'
2015-09-22T16:24:37.291744+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'

2015-09-22T16:24:37.291752+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-09-22T16:24:37.291760+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `
eval'
2015-09-22T16:24:37.291757+00:00 app[web.1]:    from /app/config.ru:in `<main>'

2015-09-22T16:24:37.291762+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-09-22T16:24:37.291768+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `
build_app_and_options_from_config'
2015-09-22T16:24:37.291765+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'

2015-09-22T16:24:37.291772+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-09-22T16:24:37.291773+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:61:in `
app'
2015-09-22T16:24:37.291780+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'

2015-09-22T16:24:37.291777+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-09-22T16:24:37.291783+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:80:in `
start'
2015-09-22T16:24:37.291786+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in `block in server'

2015-09-22T16:24:37.291790+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-09-22T16:24:37.291793+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `
server'
2015-09-22T16:24:37.291796+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'

2015-09-22T16:24:37.291800+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
2015-09-22T16:24:37.291803+00:00 app[web.1]:    from bin/rails:8:in `
require'
2015-09-22T16:24:37.291805+00:00 app[web.1]:    from bin/rails:8:in `<main>'

2015-09-22T16:24:37.322146+00:00 app[web.1]: => Booting WEBrick
2015-09-22T16:24:37.322150+00:00 app[web.1]: => Rails 4.2.2 application starting in production on http://0.0.0.0:13217
2015-09-22T16:24:37.322152+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-09-22T16:24:37.322155+00:00 app[web.1]: Exiting
2015-09-22T16:24:37.322154+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-09-22T16:24:38.408303+00:00 heroku[web.1]: Process exited with status 1
2015-09-22T16:24:38.423692+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-22T16:24:38.423692+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-22T16:24:41.679761+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 59157 -e production`
2015-09-22T16:24:44.946057+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': 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). (Gem::LoadError)
2015-09-22T16:24:44.946084+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/connection_specification.rb:174:in `
spec'
2015-09-22T16:24:44.946088+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'

2015-09-22T16:24:44.946091+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
2015-09-22T16:24:44.946096+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:45:in `
block in run_load_hooks'
2015-09-22T16:24:44.946086+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_handling.rb:50:in `establish_connection'

2015-09-22T16:24:44.946089+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
2015-09-22T16:24:44.946097+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:44:in `
each'
2015-09-22T16:24:44.946099+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'

2015-09-22T16:24:44.946100+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/base.rb:316:in `<module:ActiveRecord>'
2015-09-22T16:24:44.946102+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/base.rb:26:in `
<top (required)>'
2015-09-22T16:24:44.946103+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:118:in `<class:PredicateBuilder>'

2015-09-22T16:24:44.946104+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:2:in `<module:ActiveRecord>'
2015-09-22T16:24:44.946106+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record/relation/predicate_builder.rb:1:in `
<top (required)>'
2015-09-22T16:24:44.946107+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'

2015-09-22T16:24:44.946109+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
2015-09-22T16:24:44.946110+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `
load_dependency'
2015-09-22T16:24:44.946111+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'

2015-09-22T16:24:44.946113+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `block in eager_load!'
2015-09-22T16:24:44.946114+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `
each_value'
2015-09-22T16:24:44.946115+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies/autoload.rb:70:in `eager_load!'

2015-09-22T16:24:44.946116+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.2/lib/active_record.rb:158:in `eager_load!'
2015-09-22T16:24:44.946118+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application/finisher.rb:56:in `
each'
2015-09-22T16:24:44.946119+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'

2015-09-22T16:24:44.946122+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec'
2015-09-22T16:24:44.946124+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `
run'
2015-09-22T16:24:44.946125+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'

2015-09-22T16:24:44.946127+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
2015-09-22T16:24:44.946126+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `
block in tsort_each'
2015-09-22T16:24:44.946130+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'

2015-09-22T16:24:44.946129+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
2015-09-22T16:24:44.946134+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `
tsort_each'
2015-09-22T16:24:44.946133+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'

2015-09-22T16:24:44.946135+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers'
2015-09-22T16:24:44.946131+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `
each'
2015-09-22T16:24:44.946142+00:00 app[web.1]:    from /app/config.ru:3:in `require'

2015-09-22T16:24:44.946139+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
2015-09-22T16:24:44.946140+00:00 app[web.1]:    from /app/config/environment.rb:5:in `
<top (required)>'
2015-09-22T16:24:44.946144+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'

2015-09-22T16:24:44.946143+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2015-09-22T16:24:44.946149+00:00 app[web.1]:    from /app/config.ru:in `
new'
2015-09-22T16:24:44.946146+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'

2015-09-22T16:24:44.946153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-09-22T16:24:44.946150+00:00 app[web.1]:    from /app/config.ru:in `
<main>'
2015-09-22T16:24:44.946164+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'

2015-09-22T16:24:44.965501+00:00 app[web.1]: => Rails 4.2.2 application starting in production on http://0.0.0.0:59157
2015-09-22T16:24:44.946167+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-09-22T16:24:44.946158+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `
build_app_and_options_from_config'
2015-09-22T16:24:44.946162+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:61:in `app'

2015-09-22T16:24:44.946159+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-09-22T16:24:44.965496+00:00 app[web.1]: => Booting WEBrick
2015-09-22T16:24:44.946171+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in `
block in server'
2015-09-22T16:24:44.946175+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'

2015-09-22T16:24:44.946176+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-09-22T16:24:44.946179+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `
run_command!'
2015-09-22T16:24:44.946183+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'

2015-09-22T16:24:44.946186+00:00 app[web.1]:    from bin/rails:8:in `require'
2015-09-22T16:24:44.946187+00:00 app[web.1]:    from bin/rails:8:in `
<main>'
2015-09-22T16:24:44.965503+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-09-22T16:24:44.965504+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-09-22T16:24:44.946156+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'

2015-09-22T16:24:44.965506+00:00 app[web.1]: Exiting
2015-09-22T16:24:44.946152+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-09-22T16:24:44.946168+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/commands/server.rb:80:in `
start'
2015-09-22T16:24:45.724447+00:00 heroku[web.1]: Process exited with status 1
2015-09-22T16:24:45.739191+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-22T16:24:47.758235+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=infinite-inlet-3994.herokuapp.com request_id=c19b75bd-8c4a-427f-975d-b81f87ddc7ed fwd="46.7.54.39" dyno= connect= service= status=503 bytes=
2015-09-22T16:25:00.442110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=infinite-inlet-3994.herokuapp.com request_id=f26af351-7605-4fd8-a7f6-2da6996d5f1d fwd="46.7.54.39" dyno= connect= service= status=503 bytes=
WARNING: Toolbelt v3.42.2 update available.


下面是Rails指出的错误:

1
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). (Gem::LoadError)

当然,Heroku以默认运行PostgreSQL而闻名。

此错误有两种可能性:

  • Something is wrong with your Rails app (IE the PG gem is not loaded)
  • Heroku doesn't have the db created or accessible
  • ——

    我在Heroku上遇到这个问题的唯一时间就是我没有创建或验证数据库。

    我要做的是:

    宝石

    把你的pg gem放在gem文件的一般部分。我知道这可能会导致你的开发环境出现问题;它将允许Heroku加载gem。您可以稍后再更改:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #Gemfile
    source 'https://rubygems.org'

    gem 'pg'
    gem 'rails',        '4.2.2'
    gem 'sass-rails',   '5.0.2'
    gem 'uglifier',     '2.5.3'
    gem 'coffee-rails', '4.1.0'
    gem 'jquery-rails', '4.0.3'
    gem 'turbolinks',   '2.3.0'
    gem 'jbuilder',    '2.2.3'
    gem 'sdoc',         '0.4.0', group: :doc

    号分贝

    在Heroku中,确保已设置数据库,并已将其凭据添加到您的#config/database.yml文件中:

    enter image description here

    辅导的

    基本上,如果您已经设置了heroku pg数据库,请将凭证添加到您的database.yml文件中,然后使用上面的教程迁移到db,它应该解决这个问题。