2015-02-09 105 views
0

我正在使用Devise爲用戶註冊,它在我的本地主機上工作,但是當我將應用部署到Heroku時,當我訪問用戶註冊頁面時,我得到一個死頁面。設計用戶註冊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 
> "https://stackoverflow.com/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="https://stackoverflow.com/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="https://stackoverflow.com/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="https://stackoverflow.com/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 
> "https://stackoverflow.com/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="https://stackoverflow.com/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 
> "https://stackoverflow.com/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 
> "https://stackoverflow.com/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="https://stackoverflow.com/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]: 

謝謝!

回答

0

如果您閱讀錯誤,它看起來像new.html.erb佈局引用first_name字段,但用戶對象沒有。

編輯:您有機會在本地使用的寶石比使用heroku的寶石更好,反之亦然,所以如果這不是一個簡單的邏輯錯誤,我會尋找一個罪魁禍首。

0

我有一個類似的問題,並解決它。在我的情況下,我將用戶名遷移到用戶表,但忘記重置生產數據庫。

鑑於我的經驗,這條線在錯誤

> 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 
0

我也有類似的問題,它的原因是,你的本地主機具有填充了用戶的用戶表,但一旦您部署到Heroku,用戶表從頭開始創建,並且將爲空。

做到以下幾點: -

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

然後用色器件Sign_up並創建一個新的用戶或任何登記表。