2017-03-16 73 views
0

我有一個網站與軌道上的紅寶石生成(不是我自己),我被要求在heroku上部署它。不幸的是我在RoR方面不是很有經驗。經過大量的跟蹤和錯誤,我得到的網站在本地(與sqlite3數據庫)在Ubuntu系統上工作。Heroku上的部署失敗,PostgreSQL的ActionView ::模板::錯誤

但是當我在生產環境中將它部署到heroku時,出現錯誤。我已經嘗試遷移數據庫(heroku run rake db:migrate)並重新啓動它。我也檢查了this,但不明白: - /。

命令heroku logs顯示:

[email protected]:~/testWebsite_WORKING_LOCALLY$ heroku logs 
2017-03-13T12:05:11.768568+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
2017-03-13T12:05:11.768568+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>' 
2017-03-13T12:05:11.768569+00:00 app[web.1]: bin/rails:8:in `require' 
2017-03-13T12:05:11.768570+00:00 app[web.1]: bin/rails:8:in `<main>' 
2017-03-13T12:05:11.768638+00:00 app[web.1]: [2017-03-13 12:05:11] INFO going to shutdown ... 
2017-03-13T12:05:11.768687+00:00 app[web.1]: [2017-03-13 12:05:11] INFO WEBrick::HTTPServer#start done. 
2017-03-13T12:05:11.768708+00:00 app[web.1]: Exiting 
2017-03-13T12:05:12.011907+00:00 heroku[web.1]: Process exited with status 143 
2017-03-16T07:46:48.168709+00:00 heroku[run.9616]: Awaiting client 
2017-03-16T07:46:48.193736+00:00 heroku[run.9616]: Starting process with command `bundle exec rake db:migrate` 
2017-03-16T07:46:48.369528+00:00 heroku[run.9616]: State changed from starting to up 
2017-03-16T07:46:55.628642+00:00 heroku[run.9616]: Process exited with status 0 
2017-03-16T07:46:55.643311+00:00 heroku[run.9616]: State changed from up to complete 
2017-03-16T07:49:17.009091+00:00 heroku[web.1]: Unidling 
2017-03-16T07:49:17.009364+00:00 heroku[web.1]: State changed from down to starting 
2017-03-16T07:49:29.129238+00:00 heroku[web.1]: Starting process with command `bundle exec rails s -p 18792` 
2017-03-16T07:49:37.584645+00:00 heroku[web.1]: State changed from starting to up 
2017-03-16T07:49:37.2:00 app[web.1]: [2017-03-16 07:49:37] INFO WEBrick 1.3.1 
2017-03-16T07:49:37.201265+00:00 app[web.1]: [2017-03-16 07:49:37] INFO ruby 2.2.3 (2015-08-18) [x86_64-linux] 
2017-03-16T07:49:37.201662+00:00 app[web.1]: [2017-03-16 07:49:37] INFO WEBrick::HTTPServer#start: pid=4 port=18792 
2017-03-16T07:49:39.088134+00:00 app[web.1]: => Booting WEBrick 
2017-03-16T07:49:39.088147+00:00 app[web.1]: => Rails 4.2.4 application starting in production on http://0.0.0.0:18792 
2017-03-16T07:49:39.088148+00:00 app[web.1]: => Run `rails server -h` for more startup options 
2017-03-16T07:49:39.088148+00:00 app[web.1]: => Ctrl-C to shutdown server 
2017-03-16T07:49:39.088149+00:00 app[web.1]: Started GET "/" for 195.37.177.70 at 2017-03-16 07:49:39 +0000 
2017-03-16T07:49:39.260787+00:00 app[web.1]: Processing by HomePagesController#home_page_view as HTML 
2017-03-16T07:49:39.566106+00:00 app[web.1]: HomePage Load (14.0ms) SELECT "home_pages".* FROM "home_pages" ORDER BY "home_pages"."id" ASC LIMIT 1 
2017-03-16T07:49:39.673952+00:00 app[web.1]: Slide Load (14.2ms) SELECT "slides".* FROM "slides" WHERE (active = 't') ORDER BY "slides"."viewing_index" ASC 
2017-03-16T07:49:39.683330+00:00 app[web.1]: (1.6ms) SELECT COUNT(*) FROM "slides" WHERE (active = 't') 
2017-03-16T07:49:39.686623+00:00 app[web.1]: Rendered home_pages/home_page_view.html.haml within layouts/application (106.1ms) 
2017-03-16T07:49:39.686848+00:00 app[web.1]: Completed 500 Internal Server Error in 426ms (ActiveRecord: 77.7ms) 
2017-03-16T07:49:39.700715+00:00 app[web.1]: 
2017-03-16T07:49:39.700718+00:00 app[web.1]: ActionView::Template::Error (undefined method `testWebsite_de' for nil:NilClass): 
2017-03-16T07:49:39.700719+00:00 app[web.1]:  39: .container#content 
2017-03-16T07:49:39.700719+00:00 app[web.1]:  40: .testWebsite-short 
2017-03-16T07:49:39.700720+00:00 app[web.1]:  41:  -if I18n.locale == :de 
2017-03-16T07:49:39.700721+00:00 app[web.1]:  42:  = @home_page.testWebsite_de.html_safe 
2017-03-16T07:49:39.700722+00:00 app[web.1]:  43:  -if I18n.locale == :en 
2017-03-16T07:49:39.700722+00:00 app[web.1]:  44:  = @home_page.testWebsite_en.html_safe 
2017-03-16T07:49:39.700723+00:00 app[web.1]:  45: .teasers 
2017-03-16T07:49:39.700724+00:00 app[web.1]: app/views/home_pages/home_page_view.html.haml:42:in `_app_views_home_pages_home_page_view_html_haml___1156244683519038980_69885836641300' 
2017-03-16T07:49:39.700725+00:00 app[web.1]: 
2017-03-16T07:49:39.700725+00:00 app[web.1]: 
2017-03-16T07:49:39.695715+00:00 heroku[router]: at=info method=GET path="/" host=limitless-forest-98133.herokuapp.com request_id=cfc6c015-f0f4-4b0f-af7a-5061ab3ea342 fwd="195.37.177.70" dyno=web.1 connect=0ms service=621ms status=500 bytes=1754 protocol=http 
2017-03-16T07:49:39.979040+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=limitless-forest-98133.herokuapp.com request_id=caf0eb1c-bf56-4db5-b086-aff699644d51 fwd="195.37.177.70" dyno=web.1 connect=0ms service=17ms status=200 bytes=228 protocol=http 
2017-03-16T07:52:18.105596+00:00 heroku[run.1897]: State changed from starting to up 
2017-03-16T07:52:18.081549+00:00 heroku[run.1897]: Awaiting client 
2017-03-16T07:52:18.168375+00:00 heroku[run.1897]: Starting process with command `bundle exec rake db:migrate` 
2017-03-16T07:52:26.295869+00:00 heroku[run.1897]: State changed from up to complete 
2017-03-16T07:52:26.254496+00:00 heroku[run.1897]: Process exited with status 0 
2017-03-16T07:52:47.933811+00:00 heroku[web.1]: Restarting 
2017-03-16T07:52:47.934413+00:00 heroku[web.1]: State changed from up to starting 
2017-03-16T07:52:48.597708+00:00 app[web.1]: [2017-03-16 07:52:48] FATAL SignalException: SIGTERM 
2017-03-16T07:52:48.597722+00:00 app[web.1]: /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:174:in `select' 
2017-03-16T07:52:48.597724+00:00 app[web.1]: /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:174:in `block in start' 
2017-03-16T07:52:48.597724+00:00 app[web.1]: /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:32:in `start' 
2017-03-16T07:52:48.597725+00:00 app[web.1]: /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:162:in `start' 
2017-03-16T07:52:48.597726+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in `run' 
2017-03-16T07:52:48.597726+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start' 
2017-03-16T07:52:48.597727+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start' 
2017-03-16T07:52:48.597728+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server' 
2017-03-16T07:52:48.597729+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap' 
2017-03-16T07:52:48.597729+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server' 
2017-03-16T07:52:48.597730+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
2017-03-16T07:52:48.597731+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>' 
2017-03-16T07:52:48.597732+00:00 app[web.1]: bin/rails:8:in `require' 
2017-03-16T07:52:48.597732+00:00 app[web.1]: bin/rails:8:in `<main>' 
2017-03-16T07:52:48.597819+00:00 app[web.1]: [2017-03-16 07:52:48] INFO going to shutdown ... 
2017-03-16T07:52:48.597876+00:00 app[web.1]: [2017-03-16 07:52:48] INFO WEBrick::HTTPServer#start done. 
2017-03-16T07:52:48.597907+00:00 app[web.1]: Exiting 
2017-03-16T07:52:48.587611+00:00 heroku[web.1]: Stopping all processes with SIGTERM 
2017-03-16T07:52:48.803805+00:00 heroku[web.1]: Process exited with status 143 
2017-03-16T07:52:58.894196+00:00 heroku[web.1]: Starting process with command `bundle exec rails s -p 6725` 
2017-03-16T07:53:05.878954+00:00 app[web.1]: [2017-03-16 07:53:05] INFO WEBrick 1.3.1 
2017-03-16T07:53:05.878982+00:00 app[web.1]: [2017-03-16 07:53:05] INFO ruby 2.2.3 (2015-08-18) [x86_64-linux] 
2017-03-16T07:53:05.879354+00:00 app[web.1]: [2017-03-16 07:53:05] INFO WEBrick::HTTPServer#start: pid=4 port=6725 
2017-03-16T07:53:06.466569+00:00 heroku[web.1]: State changed from starting to up 
2017-03-16T07:53:07.473807+00:00 app[web.1]: => Booting WEBrick 
2017-03-16T07:53:07.473817+00:00 app[web.1]: => Rails 4.2.4 application starting in production on http://0.0.0.0:6725 
2017-03-16T07:53:07.473818+00:00 app[web.1]: => Run `rails server -h` for more startup options 
2017-03-16T07:53:07.473819+00:00 app[web.1]: => Ctrl-C to shutdown server 
2017-03-16T07:53:07.473820+00:00 app[web.1]: Started GET "/" for 195.37.177.70 at 2017-03-16 07:53:07 +0000 
2017-03-16T07:53:07.565021+00:00 app[web.1]: Processing by HomePagesController#home_page_view as HTML 
2017-03-16T07:53:07.678903+00:00 app[web.1]: Slide Load (1.4ms) SELECT "slides".* FROM "slides" WHERE (active = 't') ORDER BY "slides"."viewing_index" ASC 
2017-03-16T07:53:07.684860+00:00 app[web.1]: (0.9ms) SELECT COUNT(*) FROM "slides" WHERE (active = 't') 
2017-03-16T07:53:07.647395+00:00 app[web.1]: HomePage Load (2.8ms) SELECT "home_pages".* FROM "home_pages" ORDER BY "home_pages"."id" ASC LIMIT 1 
2017-03-16T07:53:07.688874+00:00 app[web.1]: Completed 500 Internal Server Error in 124ms (ActiveRecord: 23.6ms) 
2017-03-16T07:53:07.692956+00:00 app[web.1]: 
2017-03-16T07:53:07.692959+00:00 app[web.1]: ActionView::Template::Error (undefined method `testWebsite_de' for nil:NilClass): 
2017-03-16T07:53:07.692960+00:00 app[web.1]:  39: .container#content 
2017-03-16T07:53:07.692961+00:00 app[web.1]:  40: .testWebsite-short 
2017-03-16T07:53:07.692962+00:00 app[web.1]:  41:  -if I18n.locale == :de 
2017-03-16T07:53:07.687979+00:00 app[web.1]: Rendered home_pages/home_page_view.html.haml within layouts/application (31.4ms) 
2017-03-16T07:53:07.692963+00:00 app[web.1]:  43:  -if I18n.locale == :en 
2017-03-16T07:53:07.692962+00:00 app[web.1]:  42:  = @home_page.testWebsite_de.html_safe 
2017-03-16T07:53:07.692964+00:00 app[web.1]:  44:  = @home_page.testWebsite_en.html_safe 
2017-03-16T07:53:07.692968+00:00 app[web.1]: app/views/home_pages/home_page_view.html.haml:42:in `_app_views_home_pages_home_page_view_html_haml___3877761630422882463_69824471651020' 
2017-03-16T07:53:07.692969+00:00 app[web.1]: 
2017-03-16T07:53:07.692970+00:00 app[web.1]: 
2017-03-16T07:53:07.692964+00:00 app[web.1]:  45: .teasers 
2017-03-16T07:53:07.694524+00:00 heroku[router]: at=info method=GET path="/" host=limitless-forest-98133.herokuapp.com request_id=2b456a65-b611-4f75-8b51-8fc9c445c495 fwd="195.37.177.70" dyno=web.1 connect=1ms service=231ms status=500 bytes=1754 protocol=http 

可有人請給我一個提示或解釋什麼是錯,因爲我真的不明白這一點?這是源代碼的問題還是我在部署過程中出錯?

感謝 添

+0

這意味着你沒有'@ home_page' –

回答

1

檢查你的錯誤信息避免錯誤即

ActionView::Template::Error (undefined method `testWebsite_de' for nil:NilClass): 
在文件app /視圖/ home_pages/home_page_view.html.haml

:42

在行# 42 ie

@home_page.testWebsite_de.html_safe 

這裏@home_page爲零,所以用下面的代碼更正:

@home_page.try(:testWebsite_de).try(:html_safe) 

OR

@home_page.testWebsite_de.html_safe unless @home_page.nil? 
1

在你app/views/home_pages/home_page_view.html.haml

@home_page沒有任何價值,可變越來越nil值,所以你不能從@home_page變量得到testWebsite_de

可以使用

@home_page.try(:testWebsite_de).try(:html_safe)