设计用户注册Heroku部署

时间:2015-02-09 17:54:00

标签: ruby-on-rails ruby heroku devise

我正在使用Devise对用户进行签名,这可以在我的localhost上运行,但是当我将应用程序部署到Heroku时,当我访问用户注册页面时,我会看到一个死页。

我有一个修改过的注册控制器。我可以访问登录页面没问题。

以下是日志:

> 2015-02-09T17:44:06.924861+00:00 app[web.1]:   Rendered
> devise/registrations/new.html.erb within layouts/application (6.7ms)
> 2015-02-09T17:44:06.926680+00:00 app[web.1]:      9:       
> 2015-02-09T17:44:06.926678+00:00 app[web.1]:
> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f86244a8>): 2015-02-09T17:44:06.926709+00:00 app[web.1]:   app/views/devise/registrations/new.html.erb:12:in `block
> in
> _app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:44:06.926711+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:7:in
> `_app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:44:06.926714+00:00 app[web.1]: 
> 2015-02-09T17:44:06.926713+00:00 app[web.1]:  
> app/controllers/registrations_controller.rb:5:in `new'
> 2015-02-09T17:44:06.926715+00:00 app[web.1]: 
> 2015-02-09T17:44:06.697819+00:00 app[web.1]: 
> 2015-02-09T17:44:06.926701+00:00 app[web.1]:     11:         <%=
> f.label :first_name %><br /> 2015-02-09T17:44:06.697825+00:00
> app[web.1]:      9:        2015-02-09T17:44:06.686488+00:00
> app[web.1]: Processing by RegistrationsController#new as HTML
> 2015-02-09T17:44:06.695917+00:00 app[web.1]:   Rendered
> devise/registrations/new.html.erb within layouts/application (6.9ms)
> 2015-02-09T17:44:06.697823+00:00 app[web.1]:
> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f8657a60>): 2015-02-09T17:44:06.697831+00:00 app[web.1]:     13:       </div> 2015-02-09T17:44:06.697833+00:00
> app[web.1]:     14:        2015-02-09T17:44:06.697828+00:00
> app[web.1]:     11:         <%= f.label :first_name %><br />
> 2015-02-09T17:44:06.697834+00:00 app[web.1]:     15:       <div
> class="field"> 2015-02-09T17:44:06.697827+00:00 app[web.1]:     10:   
> <div class="field"> 2015-02-09T17:44:06.697830+00:00 app[web.1]:    
> 12:         <%= f.text_field :first_name, autofocus: true %>
> 2015-02-09T17:44:06.697836+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:12:in `block in
> _app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:44:06.697840+00:00 app[web.1]:  
> app/controllers/registrations_controller.rb:5:in `new'
> 2015-02-09T17:44:06.922118+00:00 app[web.1]:   Rendered
> shared/_error_messages.html.erb (0.1ms)
> 2015-02-09T17:44:06.925025+00:00 app[web.1]: Completed 500 Internal
> Server Error in 9ms 2015-02-09T17:44:06.697839+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:7:in
> `_app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:44:06.697842+00:00 app[web.1]: 
> 2015-02-09T17:44:06.913596+00:00 app[web.1]: Started GET
> "/users/sign_up" for 140.203.249.251 at 2015-02-09 17:44:06 +0000
> 2015-02-09T17:44:06.697843+00:00 app[web.1]: 
> 2015-02-09T17:44:06.741773+00:00 heroku[router]: at=info method=GET
> path="/users/sign_up" host=www.lapseapp.co
> request_id=4d86fc5a-0554-45f2-8295-79369240721e fwd="140.203.249.251"
> dyno=web.1 connect=23ms service=41ms status=500 bytes=1754
> 2015-02-09T17:44:06.932492+00:00 heroku[router]: at=info method=GET
> path="/users/sign_up" host=www.lapseapp.co
> request_id=06ee500f-54f4-404b-a024-7ec4ab7184b6 fwd="140.203.249.251"
> dyno=web.1 connect=11ms service=19ms status=500 bytes=1754
> 2015-02-09T17:49:06.821223+00:00 heroku[router]: at=info method=GET
> path="/users/sign_up" host=www.lapseapp.co
> request_id=a4847b4c-4964-4490-8726-6e045a0f88dd fwd="140.203.249.251"
> dyno=web.1 connect=1ms service=16ms status=500 bytes=1754
> 2015-02-09T17:49:06.817971+00:00 app[web.1]:   Rendered
> shared/_error_messages.html.erb (0.1ms)
> 2015-02-09T17:49:06.811058+00:00 app[web.1]: Started GET
> "/users/sign_up" for 140.203.249.251 at 2015-02-09 17:49:06 +0000
> 2015-02-09T17:49:06.813015+00:00 app[web.1]: Processing by
> RegistrationsController#new as HTML 2015-02-09T17:49:06.822040+00:00
> app[web.1]:     10:       <div class="field">
> 2015-02-09T17:49:06.822041+00:00 app[web.1]:     11:         <%=
> f.label :first_name %><br /> 2015-02-09T17:49:06.822043+00:00
> app[web.1]:     12:         <%= f.text_field :first_name, autofocus:
> true %> 2015-02-09T17:49:06.820319+00:00 app[web.1]:   Rendered
> devise/registrations/new.html.erb within layouts/application (5.6ms)
> 2015-02-09T17:49:06.820436+00:00 app[web.1]: Completed 500 Internal
> Server Error in 7ms 2015-02-09T17:49:06.822034+00:00 app[web.1]: 
> 2015-02-09T17:49:06.822036+00:00 app[web.1]:
> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f85dc2e8>): 2015-02-09T17:49:06.822038+00:00 app[web.1]:      9:        2015-02-09T17:49:06.822045+00:00
> app[web.1]:     13:       </div> 2015-02-09T17:49:06.822046+00:00
> app[web.1]:     14:        2015-02-09T17:49:06.822048+00:00
> app[web.1]:     15:       <div class="field">
> 2015-02-09T17:49:06.822051+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:12:in `block in
> _app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:06.822053+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:7:in
> `_app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:06.822054+00:00 app[web.1]:  
> app/controllers/registrations_controller.rb:5:in `new'
> 2015-02-09T17:49:06.822056+00:00 app[web.1]: 
> 2015-02-09T17:49:06.822057+00:00 app[web.1]: 
> 2015-02-09T17:49:31.058835+00:00 app[web.1]: Started GET "/" for
> 140.203.249.251 at 2015-02-09 17:49:31 +0000 2015-02-09T17:49:31.063413+00:00 app[web.1]:   Rendered
> static_pages/home.html.erb within layouts/application (0.4ms)
> 2015-02-09T17:49:31.061847+00:00 app[web.1]: Processing by
> StaticPagesController#home as HTML 2015-02-09T17:49:31.064166+00:00
> app[web.1]:   Rendered layouts/_shim.html.erb (0.0ms)
> 2015-02-09T17:49:31.065175+00:00 app[web.1]: Completed 200 OK in 3ms
> (Views: 2.5ms | ActiveRecord: 0.0ms) 2015-02-09T17:49:31.064739+00:00
> app[web.1]:   Rendered layouts/_header.html.erb (0.4ms)
> 2015-02-09T17:49:31.068932+00:00 heroku[router]: at=info method=GET
> path="/" host=guarded-harbor-5264.herokuapp.com
> request_id=ef7ee4fe-8739-479a-a4dc-1452d80fd941 fwd="140.203.249.251"
> dyno=web.1 connect=3ms service=14ms status=200 bytes=3758
> 2015-02-09T17:49:31.704180+00:00 heroku[router]: at=info method=GET
> path="/assets/application-2773672927f34d7f7089d016ab05e54d.css"
> host=guarded-harbor-5264.herokuapp.com
> request_id=f1443c12-920f-4b1c-86a2-1208f4d6868b fwd="140.203.249.251"
> dyno=web.1 connect=3ms service=249ms status=200 bytes=38232
> 2015-02-09T17:49:31.750866+00:00 heroku[router]: at=info method=GET
> path="/assets/application-be644bf15bf93ef34361c033d1949a77.js"
> host=guarded-harbor-5264.herokuapp.com
> request_id=9bd0242b-b36e-4f18-ae1d-4cb3c6826a90 fwd="140.203.249.251"
> dyno=web.1 connect=2ms service=304ms status=200 bytes=64768
> 2015-02-09T17:49:32.674478+00:00 heroku[router]: at=info method=GET
> path="/assets/bg3-c9d92c61064c79152bec9ea3dd8443ee.jpg"
> host=guarded-harbor-5264.herokuapp.com
> request_id=e7de7ba8-f26f-43d5-8da0-55e34e3ee3a0 fwd="140.203.249.251"
> dyno=web.1 connect=1ms service=1077ms status=200 bytes=876051
> 2015-02-09T17:49:33.676064+00:00 heroku[router]: at=info method=GET
> path="/favicon.ico" host=guarded-harbor-5264.herokuapp.com
> request_id=c5ad4d36-5944-457e-aeaa-99b1a1e90501 fwd="140.203.249.251"
> dyno=web.1 connect=2ms service=5ms status=200 bytes=228
> 2015-02-09T17:49:35.470439+00:00 heroku[router]: at=info method=GET
> path="/users/sign_up" host=guarded-harbor-5264.herokuapp.com
> request_id=80153935-795e-46d5-8a32-d5c3318959dc fwd="140.203.249.251"
> dyno=web.1 connect=1ms service=17ms status=500 bytes=1754
> 2015-02-09T17:49:35.459092+00:00 app[web.1]: Started GET
> "/users/sign_up" for 140.203.249.251 at 2015-02-09 17:49:35 +0000
> 2015-02-09T17:49:35.466406+00:00 app[web.1]:   Rendered
> shared/_error_messages.html.erb (0.1ms)
> 2015-02-09T17:49:35.705964+00:00 app[web.1]: Processing by
> RegistrationsController#new as HTML 2015-02-09T17:49:35.461438+00:00
> app[web.1]: Processing by RegistrationsController#new as HTML
> 2015-02-09T17:49:35.468962+00:00 app[web.1]:   Rendered
> devise/registrations/new.html.erb within layouts/application (5.9ms)
> 2015-02-09T17:49:35.469092+00:00 app[web.1]: Completed 500 Internal
> Server Error in 8ms 2015-02-09T17:49:35.470739+00:00 app[web.1]: 
> 2015-02-09T17:49:35.470742+00:00 app[web.1]:
> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f815a8f0>): 2015-02-09T17:49:35.470744+00:00 app[web.1]:      9:        2015-02-09T17:49:35.470747+00:00
> app[web.1]:     11:         <%= f.label :first_name %><br />
> 2015-02-09T17:49:35.470745+00:00 app[web.1]:     10:       <div
> class="field"> 2015-02-09T17:49:35.470752+00:00 app[web.1]:     14:   
> 2015-02-09T17:49:35.470749+00:00 app[web.1]:     12:         <%=
> f.text_field :first_name, autofocus: true %>
> 2015-02-09T17:49:35.470750+00:00 app[web.1]:     13:       </div>
> 2015-02-09T17:49:35.470757+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:12:in `block in
> _app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:35.470758+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:7:in
> `_app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:35.470753+00:00 app[web.1]:     15:       <div
> class="field"> 2015-02-09T17:49:35.470760+00:00 app[web.1]:  
> app/controllers/registrations_controller.rb:5:in `new'
> 2015-02-09T17:49:35.470763+00:00 app[web.1]: 
> 2015-02-09T17:49:35.470762+00:00 app[web.1]: 
> 2015-02-09T17:49:35.698893+00:00 app[web.1]: Started GET
> "/users/sign_up" for 140.203.249.251 at 2015-02-09 17:49:35 +0000
> 2015-02-09T17:49:35.754648+00:00 heroku[router]: at=info method=GET
> path="/users/sign_up" host=guarded-harbor-5264.herokuapp.com
> request_id=74c6f5b6-d19c-4f02-8c7a-a58ddf606506 fwd="140.203.249.251"
> dyno=web.1 connect=2ms service=67ms status=500 bytes=1754
> 2015-02-09T17:49:35.740666+00:00 app[web.1]:   Rendered
> shared/_error_messages.html.erb (12.3ms)
> 2015-02-09T17:49:35.743786+00:00 app[web.1]: Completed 500 Internal
> Server Error in 38ms 2015-02-09T17:49:35.743587+00:00 app[web.1]:  
> Rendered devise/registrations/new.html.erb within layouts/application
> (35.6ms) 2015-02-09T17:49:35.753676+00:00 app[web.1]: 
> 2015-02-09T17:49:35.753682+00:00 app[web.1]:      9:       
> 2015-02-09T17:49:35.753680+00:00 app[web.1]:
> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f811f0c0>): 2015-02-09T17:49:35.753683+00:00 app[web.1]:     10:       <div class="field">
> 2015-02-09T17:49:35.753691+00:00 app[web.1]:     14:       
> 2015-02-09T17:49:35.753692+00:00 app[web.1]:     15:       <div
> class="field"> 2015-02-09T17:49:35.753685+00:00 app[web.1]:     11:   
> <%= f.label :first_name %><br /> 2015-02-09T17:49:35.753687+00:00
> app[web.1]:     12:         <%= f.text_field :first_name, autofocus:
> true %> 2015-02-09T17:49:35.753694+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:12:in `block in
> _app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:35.753689+00:00 app[web.1]:     13:       </div>
> 2015-02-09T17:49:35.753697+00:00 app[web.1]:  
> app/controllers/registrations_controller.rb:5:in `new'
> 2015-02-09T17:49:35.753696+00:00 app[web.1]:  
> app/views/devise/registrations/new.html.erb:7:in
> `_app_views_devise_registrations_new_html_erb___2767088950509430214_70209766571260'
> 2015-02-09T17:49:35.753699+00:00 app[web.1]: 
> 2015-02-09T17:49:35.753700+00:00 app[web.1]:

谢谢!

3 个答案:

答案 0 :(得分:0)

如果您读取错误,看起来new.html.erb布局引用first_name字段,但User对象没有。

编辑:您在本地工作的宝石有可能比heroku更新,反之亦然,所以如果这不是简单的话我会在那里寻找罪魁祸首逻辑错误。

答案 1 :(得分:0)

我有类似的问题并解决了它。在我的情况下,我将用户名迁移到users表,但忘记重置生产数据库。

根据我的经验,错误中的这一行

> ActionView::Template::Error (undefined method `first_name' for
> #<User:0x007fb5f85dc2e8>)...

可能是由您最近执行的迁移引起的。

如果是这种情况,以下步骤将解决问题:

$ heroku pg:reset DATABASE    # Reset the production database
$ heroku run rake db:migrate  # Inform Heroku of your new database schema

答案 2 :(得分:0)

我遇到了类似的问题,原因是你的本地主机上有用户填充的用户表,但是一旦你部署到Heroku,用户表就会从头开始创建,并且是空的。

执行以下操作: -

heroku login
heroku rake db:create
heroku rake db:migrate

然后使用设计Sign_up并创建一个新用户或任何注册表单。