我正在关注railstutorial.org上的rails教程。我的下一步是将我的应用程序部署到Heroku。当我将应用程序部署到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 butlera10@gmail.com
2015-10-16T00:01:35.747968+00:00 heroku[api]: Release v11 created by butlera10@gmail.com
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 butlera10@gmail.com
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+\-.]+@[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 :(得分:3)
正如nayiaw所指出的那样,当你想要#has_secure_password时,看起来你正试图调用#has_secured_password。换句话说,您的代码中似乎存在拼写错误。如果查看复制对象下方的堆栈跟踪线,它将指向用户模型中的第8行。我的猜测是输入错误,你可能有“has_secured_password”,当它真的应该是“has_secure_password”
您也可以执行类似
的操作git grep has_secured_password
在项目目录中以查看该行的来源。