Ich versuche, eine einfache Rails-App bereitzustellen, die auf die openweathermap-API zugreift und sie abruft und die Informationen anzeigt. Vor Ort konnte ich die Ergebnisse suchen und sehen, aber nach der Bereitstellung bei Heroku erhalte ich jedes Mal einen Fehler, wenn ich versuche, Daten von der API abzurufen. In den Protokollen heißt esFehler bei der Bereitstellung einer API-Rails-App auf Heroku
ActionView :: Template :: Fehler (undefinierte Methode `[] 'für Nil: NilClass): 2017-03-28T23: 13: 39.240642 + 00: 00 App [Web.1] [9630d05d-78ea-4e76-9c22-17a05ce56b42] 1:
Prognose für <% = @ w [ "name"]%>, <% = @ w [ "sys"] [ "Land"]%>
etc ..
Aber ich weiß wirklich nicht, wo es zu beheben
2017-03-28T22:34:26.249586+00:00 heroku[router]: at=info method=GET path="/assets/application-ee2ce37cbf576e743a25b85e1834b055fe1564a1a8b891ed64f7fd521f2f88dc.js" host=frozen-river-81321.herokuapp.com request_id=4954e1e4-8411-4365-b36f-87bddf0b5693 fwd="83.138.193.223" dyno=web.1 connect=0ms service=6ms status=304 bytes=48 protocol=https
2017-03-28T22:34:26.489479+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=frozen-river-81321.herokuapp.com request_id=b25b4025-5c8e-4e70-8008-ad3613062e57 fwd="83.138.193.223" dyno=web.1 connect=1ms service=1ms status=200 bytes=143 protocol=https
2017-03-28T22:34:30.360691+00:00 heroku[router]: at=info method=GET path="/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" host=frozen-river-81321.herokuapp.com request_id=6148657c-8bdf-4ff0-b503-5b2f798c48bd fwd="83.138.193.223" dyno=web.1 connect=1ms service=48ms status=500 bytes=1669 protocol=https
2017-03-28T22:34:30.333448+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] Started GET "/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" for 83.138.193.223 at 2017-03-28 22:34:30 +0000
2017-03-28T22:34:30.336021+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] Processing by ForecastController#show as HTML
2017-03-28T22:34:30.336091+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] Parameters: {"utf8"=>"✓", "lat"=>"76.26", "lon"=>"78.5", "commit"=>"Search"}
2017-03-28T22:34:30.377650+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] Completed 500 Internal Server Error in 41ms
2017-03-28T22:34:30.378635+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd]
2017-03-28T22:34:30.378666+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] NoMethodError (undefined method `[]' for nil:NilClass):
2017-03-28T22:34:30.378724+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd]
2017-03-28T22:34:30.378760+00:00 app[web.1]: [6148657c-8bdf-4ff0-b503-5b2f798c48bd] app/controllers/forecast_controller.rb:10:in `show'
2017-03-28T22:39:39.000000+00:00 app[api]: Build started by user
2017-03-28T22:39:59.041896+00:00 app[api]: Release v8 created by user
2017-03-28T22:39:59.041896+00:00 app[api]: Deploy fb86924 by user
2017-03-28T22:39:59.418597+00:00 heroku[web.1]: Restarting
2017-03-28T22:39:59.419192+00:00 heroku[web.1]: State changed from up to starting
2017-03-28T22:39:39.000000+00:00 app[api]: Build succeeded
2017-03-28T22:39:59.349997+00:00 app[api]: Release v8 created by user
2017-03-28T22:40:00.214967+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-03-28T22:40:00.229628+00:00 app[web.1]: === puma shutdown: 2017-03-28 22:40:00 +0000 ===
2017-03-28T22:40:00.229632+00:00 app[web.1]: - Goodbye!
2017-03-28T22:40:00.229478+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-03-28T22:40:00.230195+00:00 app[web.1]: Exiting
2017-03-28T22:40:00.540700+00:00 heroku[web.1]: Process exited with status 0
2017-03-28T22:40:02.360668+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 55627 -e production`
2017-03-28T22:40:06.219721+00:00 app[web.1]: => Booting Puma
2017-03-28T22:40:06.219741+00:00 app[web.1]: => Rails 5.0.2 application starting in production on http://0.0.0.0:55627
2017-03-28T22:40:06.219742+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-03-28T22:40:06.219743+00:00 app[web.1]: Puma starting in single mode...
2017-03-28T22:40:06.219748+00:00 app[web.1]: * Version 3.8.2 (ruby 2.2.6-p396), codename: Sassy Salamander
2017-03-28T22:40:06.219749+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-03-28T22:40:06.219844+00:00 app[web.1]: * Listening on tcp://0.0.0.0:55627
2017-03-28T22:40:06.220162+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-28T22:40:06.219749+00:00 app[web.1]: * Environment: production
2017-03-28T22:40:06.598858+00:00 heroku[web.1]: State changed from starting to up
2017-03-28T22:40:42.536212+00:00 heroku[router]: at=info method=GET path="/" host=frozen-river-81321.herokuapp.com request_id=612b3cbc-181e-469d-9aaa-873bbf9968f2 fwd="83.138.193.223" dyno=web.1 connect=0ms service=52ms status=200 bytes=1849 protocol=http
2017-03-28T22:40:42.467816+00:00 app[web.1]: [612b3cbc-181e-469d-9aaa-873bbf9968f2] Started GET "/" for 83.138.193.223 at 2017-03-28 22:40:42 +0000
2017-03-28T22:40:42.469755+00:00 app[web.1]: [612b3cbc-181e-469d-9aaa-873bbf9968f2] Processing by ForecastController#index as HTML
2017-03-28T22:40:42.510151+00:00 app[web.1]: [612b3cbc-181e-469d-9aaa-873bbf9968f2] Rendering forecast/index.html.erb within layouts/application
2017-03-28T22:40:42.514148+00:00 app[web.1]: [612b3cbc-181e-469d-9aaa-873bbf9968f2] Rendered forecast/index.html.erb within layouts/application (3.9ms)
2017-03-28T22:40:42.515750+00:00 app[web.1]: [612b3cbc-181e-469d-9aaa-873bbf9968f2] Completed 200 OK in 46ms (Views: 6.8ms)
2017-03-28T22:40:43.593017+00:00 heroku[router]: at=info method=GET path="/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css" host=frozen-river-81321.herokuapp.com request_id=4a90a1ba-f4e4-4f7c-a943-87d4f1a3970e fwd="83.138.193.223" dyno=web.1 connect=0ms service=2ms status=200 bytes=195 protocol=http
2017-03-28T22:40:43.575325+00:00 heroku[router]: at=info method=GET path="/assets/application-ee2ce37cbf576e743a25b85e1834b055fe1564a1a8b891ed64f7fd521f2f88dc.js" host=frozen-river-81321.herokuapp.com request_id=6135d581-15ab-473d-a87a-1596e7e03090 fwd="83.138.193.223" dyno=web.1 connect=0ms service=6ms status=200 bytes=46469 protocol=http
2017-03-28T22:40:44.234523+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=frozen-river-81321.herokuapp.com request_id=be9a2e95-846e-4d30-851b-81bafa7e56f7 fwd="83.138.193.223" dyno=web.1 connect=0ms service=1ms status=200 bytes=143 protocol=http
2017-03-28T22:40:47.756522+00:00 heroku[router]: at=info method=GET path="/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" host=frozen-river-81321.herokuapp.com request_id=9c9cbecd-7e71-4e94-a776-a29666ef6f9d fwd="83.138.193.223" dyno=web.1 connect=0ms service=45ms status=500 bytes=1669 protocol=http
2017-03-28T22:40:47.716158+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] Started GET "/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" for 83.138.193.223 at 2017-03-28 22:40:47 +0000
2017-03-28T22:40:47.717619+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] Processing by ForecastController#show as HTML
2017-03-28T22:40:47.717714+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] Parameters: {"utf8"=>"✓", "lat"=>"76.26", "lon"=>"78.5", "commit"=>"Search"}
2017-03-28T22:40:47.757911+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] Completed 500 Internal Server Error in 40ms
2017-03-28T22:40:47.758737+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d]
2017-03-28T22:40:47.758792+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] NoMethodError (undefined method `[]' for nil:NilClass):
2017-03-28T22:40:47.758844+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d]
2017-03-28T22:40:47.758878+00:00 app[web.1]: [9c9cbecd-7e71-4e94-a776-a29666ef6f9d] app/controllers/forecast_controller.rb:10:in `show'
2017-03-28T23:12:19.347563+00:00 heroku[web.1]: Restarting
2017-03-28T23:12:19.348091+00:00 heroku[web.1]: State changed from up to starting
2017-03-28T23:12:20.005914+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-03-28T23:12:20.018999+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-03-28T23:12:20.019211+00:00 app[web.1]: === puma shutdown: 2017-03-28 23:12:20 +0000 ===
2017-03-28T23:12:20.019217+00:00 app[web.1]: - Goodbye!
2017-03-28T23:12:20.019356+00:00 app[web.1]: Exiting
2017-03-28T23:12:20.264562+00:00 heroku[web.1]: Process exited with status 0
2017-03-28T23:12:22.066287+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 36303 -e production`
2017-03-28T23:12:26.311385+00:00 app[web.1]: => Booting Puma
2017-03-28T23:12:26.311398+00:00 app[web.1]: => Rails 5.0.2 application starting in production on http://0.0.0.0:36303
2017-03-28T23:12:26.311399+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-03-28T23:12:26.311400+00:00 app[web.1]: Puma starting in single mode...
2017-03-28T23:12:26.311404+00:00 app[web.1]: * Version 3.8.2 (ruby 2.2.6-p396), codename: Sassy Salamander
2017-03-28T23:12:26.311405+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-03-28T23:12:26.311406+00:00 app[web.1]: * Environment: production
2017-03-28T23:12:26.311509+00:00 app[web.1]: * Listening on tcp://0.0.0.0:36303
2017-03-28T23:12:26.311880+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-28T23:12:26.769039+00:00 heroku[web.1]: State changed from starting to up
2017-03-28T23:13:33.521802+00:00 heroku[router]: at=info method=GET path="/" host=frozen-river-81321.herokuapp.com request_id=455bb1ab-e6d2-4825-9628-c1553b31a785 fwd="83.138.193.223" dyno=web.1 connect=1ms service=53ms status=200 bytes=1849 protocol=http
2017-03-28T23:13:33.642413+00:00 heroku[router]: at=info method=GET path="/assets/application-d403d1f8080b3ad942ca24506e1f1740ea2e952a983bd838c871305f1d738e17.js" host=frozen-river-81321.herokuapp.com request_id=073f6766-124f-4294-8906-bec4e53e6866 fwd="83.138.193.223" dyno=web.1 connect=1ms service=5ms status=200 bytes=46527 protocol=http
2017-03-28T23:13:33.654785+00:00 heroku[router]: at=info method=GET path="/assets/application-38d14876a278d516415b9f33c99616f2f16aee4b8f502e55085ad10a5781bbdd.css" host=frozen-river-81321.herokuapp.com request_id=41a6d3e5-2b4c-4ce4-8fcf-c821a2c0f00f fwd="83.138.193.223" dyno=web.1 connect=1ms service=2ms status=200 bytes=217 protocol=http
2017-03-28T23:13:33.449653+00:00 app[web.1]: [455bb1ab-e6d2-4825-9628-c1553b31a785] Started GET "/" for 83.138.193.223 at 2017-03-28 23:13:33 +0000
2017-03-28T23:13:33.454539+00:00 app[web.1]: [455bb1ab-e6d2-4825-9628-c1553b31a785] Processing by ForecastController#index as HTML
2017-03-28T23:13:33.487661+00:00 app[web.1]: [455bb1ab-e6d2-4825-9628-c1553b31a785] Rendering forecast/index.html.erb within layouts/application
2017-03-28T23:13:33.494523+00:00 app[web.1]: [455bb1ab-e6d2-4825-9628-c1553b31a785] Rendered forecast/index.html.erb within layouts/application (6.7ms)
2017-03-28T23:13:33.496670+00:00 app[web.1]: [455bb1ab-e6d2-4825-9628-c1553b31a785] Completed 200 OK in 44ms (Views: 10.8ms)
2017-03-28T23:13:34.546011+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=frozen-river-81321.herokuapp.com request_id=51712a1f-3d81-4a80-bc1a-3d8ea6415c30 fwd="83.138.193.223" dyno=web.1 connect=1ms service=2ms status=200 bytes=143 protocol=http
2017-03-28T23:13:39.242712+00:00 heroku[router]: at=info method=GET path="/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" host=frozen-river-81321.herokuapp.com request_id=9630d05d-78ea-4e76-9c22-17a05ce56b42 fwd="83.138.193.223" dyno=web.1 connect=2ms service=53ms status=500 bytes=1669 protocol=http
2017-03-28T23:13:39.198411+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Processing by ForecastController#show as HTML
2017-03-28T23:13:39.197228+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Started GET "/forecast/show?utf8=%E2%9C%93&lat=76.26&lon=78.5&commit=Search" for 83.138.193.223 at 2017-03-28 23:13:39 +0000
2017-03-28T23:13:39.198518+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Parameters: {"utf8"=>"✓", "lat"=>"76.26", "lon"=>"78.5", "commit"=>"Search"}
2017-03-28T23:13:39.236523+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Rendering forecast/show.html.erb within layouts/application
2017-03-28T23:13:39.238896+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Completed 500 Internal Server Error in 40ms
2017-03-28T23:13:39.238659+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] Rendered forecast/show.html.erb within layouts/application (2.0ms)
2017-03-28T23:13:39.240291+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42]
2017-03-28T23:13:39.240332+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] ActionView::Template::Error (undefined method `[]' for nil:NilClass):
2017-03-28T23:13:39.240642+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] 1: <h1>Forecast for <%[email protected]["name"] %> , <%[email protected]["sys"]["country"] %></h1>
2017-03-28T23:13:39.240643+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] 2: <p>Find me in app/views/forecast/show.html.erb</p>
2017-03-28T23:13:39.240645+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] 4: <div class="result">
2017-03-28T23:13:39.240644+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] 3: <% if [email protected]? %>
2017-03-28T23:13:39.240671+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42]
2017-03-28T23:13:39.240709+00:00 app[web.1]: [9630d05d-78ea-4e76-9c22-17a05ce56b42] app/views/forecast/show.html.erb:1:in `_app_views_forecast_show_html_erb__4480134760202078404_70214950094520
hast du 'heroku run rake db: migrate' ausgeführt? –
@ TomaszBubała ja ich habe es ausgeführt. Immer noch der gleiche Fehler "Es tut uns leid, aber etwas ging schief." –