2015-10-16 325 views
0

我在railsstutorial.org上關注rails教程。我的下一步是將我的應用程序部署到Heroku。當我部署應用的Heroku,它給了我一個錯誤說:Rails教程Heroku應用程序錯誤

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. 

這裏是我的Heroku的日誌文件:

Your version of git is 1.9.4.. Which has serious security vulnerabilities. 
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x 
2015-10-15T23:33:50.886651+00:00 heroku[web.1]: State changed from starting to crashed 
2015-10-15T23:36:42.674698+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=cbb2ea7f-a774-4ab2-960f-9c0e0717a8ea fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:36:43.560640+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=28defc83-3012-457b-985d-3b46acc61248 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:39:07.288428+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=4ba7be07-c257-4b2a-b3f6-d67e38349eed fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:39:07.434790+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=94ba475b-1100-46ae-9a1c-400ba24da2f0 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:39:24.953214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=d76bc985-4a0c-4e38-91a9-0aee8a55951f fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:39:25.362551+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=a09efac9-dd70-4035-a402-d0960af92549 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-15T23:57:26.983461+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 7986 -e production` 
2015-10-15T23:57:24.121569+00:00 heroku[web.1]: State changed from crashed to starting 
2015-10-15T23:57:30.953715+00:00 app[web.1]: => Booting Puma 
2015-10-15T23:57:30.953742+00:00 app[web.1]: => Rails 4.2.4 application starting in production on http://0.0.0.0:7986 
2015-10-15T23:57:30.953743+00:00 app[web.1]: => Run `rails server -h` for more startup options 
2015-10-15T23:57:30.953744+00:00 app[web.1]: => Ctrl-C to shutdown server 
2015-10-15T23:57:31.860563+00:00 app[web.1]: Exiting 
2015-10-15T23:57:31.862117+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined local variable or method `has_secured_password' for User (call 'User.connection' to establish a connection):Class (NameError) 
2015-10-15T23:57:31.862138+00:00 app[web.1]: from /app/app/models/user.rb:8:in `<class:User>' 
2015-10-15T23:57:31.862156+00:00 app[web.1]: from /app/app/models/user.rb:1:in `<top (required)>' 
2015-10-15T23:57:31.862177+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require' 
2015-10-15T23:57:31.862195+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require' 

2015-10-15T23:57:31.862208+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency' 2015-10-15T23:57:31.862224+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require' 
2015-10-15T23:57:31.862239+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:360:in `require_or_load' 2015-10-15T23:57:31.862266+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:317:in `depend_on' 
2015-10-15T23:57:31.862293+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:233:in `require_dependency' 
2015-10-15T23:57:31.862321+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `each' 
2015-10-15T23:57:31.862306+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!' 
2015-10-15T23:57:31.862350+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `each' 
2015-10-15T23:57:31.862336+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `block in eager_load!' 
2015-10-15T23:57:31.862366+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `eager_load!' 
2015-10-15T23:57:31.862386+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:346:in `eager_load!' 
2015-10-15T23:57:31.862398+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `each' 
2015-10-15T23:57:31.862411+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>' 
2015-10-15T23:57:31.862436+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec' 
2015-10-15T23:57:31.862464+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run' 
2015-10-15T23:57:31.862479+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers' 
2015-10-15T23:57:31.862493+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-10-15T23:57:31.862504+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-10-15T23:57:31.862518+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-10-15T23:57:31.862533+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-10-15T23:57:31.862548+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each' 
2015-10-15T23:57:31.862563+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-10-15T23:57:31.862603+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each' 
2015-10-15T23:57:31.862617+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers' 
2015-10-15T23:57:31.862633+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!' 
2015-10-15T23:57:31.862648+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>' 
2015-10-15T23:57:31.862679+00:00 app[web.1]: from /app/config.ru:3:in `block in <main>' 
2015-10-15T23:57:31.862663+00:00 app[web.1]: from /app/config.ru:3:in `require' 
2015-10-15T23:57:31.862693+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-10-15T23:57:31.862718+00:00 app[web.1]: from /app/config.ru:in `new' 
2015-10-15T23:57:31.862706+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-10-15T23:57:31.862734+00:00 app[web.1]: from /app/config.ru:in `<main>' 
2015-10-15T23:57:31.862776+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-10-15T23:57:31.862792+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-10-15T23:57:31.862807+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-10-15T23:57:31.862821+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-10-15T23:57:31.862834+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-10-15T23:57:31.862879+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-10-15T23:57:31.862864+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-10-15T23:57:31.862894+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start' 
2015-10-15T23:57:31.862847+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/server.rb:61:in `app' 
2015-10-15T23:57:31.862921+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server' 
2015-10-15T23:57:31.862948+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap' 
2015-10-15T23:57:31.862961+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server' 
2015-10-15T23:57:31.862973+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
2015-10-15T23:57:31.862988+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>' 
2015-10-15T23:57:31.863004+00:00 app[web.1]: from bin/rails:4:in `require' 
2015-10-15T23:57:31.863018+00:00 app[web.1]: from bin/rails:4:in `<main>' 
2015-10-15T23:57:32.859780+00:00 heroku[web.1]: State changed from starting to crashed 
2015-10-15T23:57:32.857005+00:00 heroku[web.1]: Process exited with status 1 
2015-10-16T00:01:35.819809+00:00 heroku[slug-compiler]: Slug compilation started 
2015-10-16T00:01:35.819819+00:00 heroku[slug-compiler]: Slug compilation finished 
2015-10-16T00:01:35.747968+00:00 heroku[api]: Deploy e6ed5b4 by [email protected] 
2015-10-16T00:01:35.747968+00:00 heroku[api]: Release v11 created by [email protected] 
2015-10-16T00:01:35.972558+00:00 heroku[web.1]: State changed from crashed to starting 
2015-10-16T00:01:39.613244+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb` 
2015-10-16T00:01:42.310288+00:00 app[web.1]: Puma starting in single mode... 
2015-10-16T00:01:42.310307+00:00 app[web.1]: * Version 2.11.1 (ruby 2.0.0-p645), codename: Intrepid Squirrel 
2015-10-16T00:01:42.310309+00:00 app[web.1]: * Min threads: 0, max threads: 16 
2015-10-16T00:01:42.310310+00:00 app[web.1]: * Environment: production 
2015-10-16T00:01:45.975901+00:00 app[web.1]: * Listening on tcp://0.0.0.0:9292 
2015-10-16T00:01:45.976271+00:00 app[web.1]: Use Ctrl-C to stop 
2015-10-16T00:01:49.599802+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by [email protected] 
2015-10-16T00:01:52.459341+00:00 heroku[run.4849]: Awaiting client 
2015-10-16T00:01:52.496893+00:00 heroku[run.4849]: Starting process with command `bundle exec rake db:migrate` 
2015-10-16T00:01:52.850289+00:00 heroku[run.4849]: State changed from starting to up 
2015-10-16T00:01:59.668556+00:00 heroku[run.4849]: Process exited with status 0 
2015-10-16T00:01:59.674461+00:00 heroku[run.4849]: State changed from up to complete 
2015-10-16T00:02:39.725945+00:00 heroku[web.1]: Stopping process with SIGKILL 
2015-10-16T00:02:39.725945+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2015-10-16T00:02:41.099174+00:00 heroku[web.1]: State changed from starting to crashed 
2015-10-16T00:02:41.065951+00:00 heroku[web.1]: Process exited with status 137 
2015-10-16T00:03:10.642913+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=441707a4-6407-48fe-9e04-35f8a7a68dd5 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:03:10.882972+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=7d301278-0040-48a8-ae80-992936681b30 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:03:15.576603+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=7e558323-1f30-43df-84bb-db6b7d9b6e1c fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:03:15.731893+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=db7c42e0-1ea2-4d95-8a10-07336adec3fc fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:03:17.610215+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=9dac3a5f-ee0c-49b2-b1a9-b6133ac6e862 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:03:17.821084+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=308f51a0-0bbf-46e4-a7ca-6ab6175d4c90 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:04:54.511133+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=53371904-5090-4ef2-b612-c5844e06b994 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:04:54.826183+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=f3e1a015-7a40-4d20-a407-d83a13617368 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:04:59.367280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-coast-3953.herokuapp.com request_id=f3d9a09c-2aff-4a66-86eb-a1561b68132d fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 
2015-10-16T00:04:59.593237+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-coast-3953.herokuapp.com request_id=8456c0bc-0e0c-49ce-8d9f-9fd2de9173a4 fwd="172.79.90.237" dyno= connect= service= status=503 bytes= 

我假設(但不知道)線之下是錯誤在我的應用程序多數民衆贊成,但我不知道如何來糾正錯誤:

/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined local variable or method `has_secured_password' for User (call 'User.connection' to establish a connection):Class (NameError) 

這裏是我的user.rb文件:

class User < ActiveRecord::Base 
    before_save { self.email = email.downcase}   
    validates :name, presence: true, length: { maximum: 50 } 
    VALID_EMAIL_REGEX = /\A[\w+\-.][email protected][a-z\d\-.]+\.[a-z]+\z/i 
    validates :email, presence: true, length: { maximum: 255 }, 
        format: { with: VALID_EMAIL_REGEX }, 
        uniqueness: {case_sensitive: false} 
    has_secure_password 
    validates :password, length: { minimum: 6 }     
end 

有人能告訴我問題是什麼以及我如何解決它?提前致謝!

+0

你確定它叫'has_secured_pa​​ssword',而不是'has_secure_password'? – nayiaw

+0

@nayiaw我正在尋找什麼文件來改變它?這是你在我的user.rb文件中建議的正確方法。 –

回答

3

正如nayiaw指出的那樣,當您可能指#has_secure_password時,它看起來像是在嘗試調用#has_secured_pa​​ssword。換句話說,它看起來像你的代碼中有一個錯字。如果您查看複製的曲線下方的堆棧跟蹤線,它將指向用戶模型中的第8行。我的猜測是,錯字是存在的,你可能有「has_secured_pa​​ssword」,當它應該真正做到「has_secure_password」

你也可以做類似

git grep has_secured_password 

在你的項目目錄,看看該行來自。