Webpack error on Heroku Deployment - ruby-on-rails

Running my rails app locally works fine. Then I deployed it to Heroku successfully but when opening the app I get the error:
"We're sorry, but something went wrong.
If you are the application owner check the logs for more information."
I'm new to using Heroku, this is my first deployed app so not completely sure of how everything works. In my heroku logs it says that:
ActionView::Template::Error (Webpacker can't find application.css in
/app/public/packs/manifest.json. Possible causes:
You want to set webpacker.yml value of compile to true for your environment
Webpack has not yet re-run to reflect updates.
You have misconfigured Webpacker's config/webpacker.yml file. unless you are using the webpack -w or the webpack-dev-server.
Your Webpack configuration is not creating a manifest.
Anyone that has had the same problem or has any tips on how to try and solve this?
This is the whole heroku log:
2017-11-19T12:30:56.336758+00:00 app[web.1]: I, [2017-11-19T12:30:56.336675 #4] INFO -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] Started GET "/" for 85.228.31.12 at 2017-11-19 12:30:56 +0000
2017-11-19T12:30:56.338912+00:00 app[web.1]: I, [2017-11-19T12:30:56.338848 #4] INFO -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] Rendered react_view/index.html.erb within layouts/application (0.7ms)
2017-11-19T12:30:56.337434+00:00 app[web.1]: I, [2017-11-19T12:30:56.337362 #4] INFO -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] Processing by ReactViewController#index as HTML
2017-11-19T12:30:56.338062+00:00 app[web.1]: I, [2017-11-19T12:30:56.337995 #4] INFO -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] Rendering react_view/index.html.erb within layouts/application
2017-11-19T12:30:56.339074+00:00 app[web.1]: I, [2017-11-19T12:30:56.339014 #4] INFO -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] Completed 500 Internal Server Error in 2ms
2017-11-19T12:30:56.339692+00:00 app[web.1]: F, [2017-11-19T12:30:56.339632 #4] FATAL -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c]
2017-11-19T12:30:56.339766+00:00 app[web.1]: F, [2017-11-19T12:30:56.339696 #4] FATAL -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] ActionView::Template::Error (Webpacker can't find application.css in /app/public/packs/manifest.json. Possible causes:
2017-11-19T12:30:56.339768+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2017-11-19T12:30:56.339770+00:00 app[web.1]: 2. Webpack has not yet re-run to reflect updates.
2017-11-19T12:30:56.339771+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2017-11-19T12:30:56.339769+00:00 app[web.1]: unless you are using the `webpack -w` or the webpack-dev-server.
2017-11-19T12:30:56.339772+00:00 app[web.1]: 4. Your Webpack configuration is not creating a manifest.
2017-11-19T12:30:56.339974+00:00 app[web.1]: [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] 3: <%= javascript_pack_tag 'application' %>
2017-11-19T12:30:56.340038+00:00 app[web.1]: F, [2017-11-19T12:30:56.339975 #4] FATAL -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c]
2017-11-19T12:30:56.340104+00:00 app[web.1]: F, [2017-11-19T12:30:56.340050 #4] FATAL -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] app/views/react_view/index.html.erb:2:in `_app_views_react_view_index_html_erb___547572771215860275_34419720'
2017-11-19T12:30:56.339974+00:00 app[web.1]: [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] 4: <%= javascript_pack_tag 'ReactHome' %>
2017-11-19T12:30:56.339773+00:00 app[web.1]: Your manifest contains:
2017-11-19T12:30:56.339775+00:00 app[web.1]: }
2017-11-19T12:30:56.339774+00:00 app[web.1]: {
2017-11-19T12:30:56.339775+00:00 app[web.1]: ):
2017-11-19T12:30:56.339972+00:00 app[web.1]: F, [2017-11-19T12:30:56.339903 #4] FATAL -- : [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] 1: <script>window.__theme = 'bs4';</script>
2017-11-19T12:30:56.339973+00:00 app[web.1]: [0b584fb1-2c9e-41e9-bfe4-19cbf6523a6c] 2: <%= stylesheet_pack_tag 'application' %>
`

I had this error, tried to compile and also got :
$ rake assets:precompile RAILS_ENV=production
...
rails aborted!
No such middleware to insert after: ActionDispatch::Static
Solved it thanks to this thread by turning with an ENV
# config/environments/production.rb
config.public_file_server.enabled=true` # ENV['RAILS_SERVE_STATIC_FILES'].present?

Related

Rails app showing memory stats in heroku logs

I signed up on my rails app on heroku and get the following error on my heroku logs. Meanwhile, the user has been saved to the database.
Anyone with advise on how to proceed pls. I am using devise gem, tried both Puma and Thin servers. Still get the same error. App location is at: https://naijasinglesmeet.herokuapp.com
Sign up for an account and this is what I get in my logs below:
Please advise
2019-10-08T19:55:38.458871+00:00 app[web.1]: I, [2019-10-08T19:55:26.203972 #4] INFO -- : [41600c35-8749-48f2-9c8a-8428f4a92dea] Completed 200 OK in 10ms (Views: 7.5ms | ActiveRecord: 0.0ms)
2019-10-08T19:55:38.458873+00:00 app[web.1]: I, [2019-10-08T19:55:38.298348 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Started POST "/users" for 41.217.104.185 at 2019-10-08 19:55:38 +0000
2019-10-08T19:55:38.458875+00:00 app[web.1]: I, [2019-10-08T19:55:38.299628 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Processing by RegistrationsController#create as HTML
2019-10-08T19:55:38.45889+00:00 app[web.1]: I, [2019-10-08T19:55:38.299753 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Parameters: {"utf8"=>"✓", "authenticity_token"=>"amK9Wje7yZ2DJDtylpzVrY9HrYgc7pmtBMnbl/lrdU5/dW+A00CGgDAW8uAtyfiUDF0tvSZtCt56gOeZsmO+mA==", "user"=>{"username"=>"iamyinka", "first_name"=>"Yinka", "last_name"=>"Ash", "email"=>"iamhere#yinka.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
2019-10-08T19:55:38.458892+00:00 app[web.1]: D, [2019-10-08T19:55:38.458466 #4] DEBUG -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] (0.7ms) BEGIN
2019-10-08T19:55:38.993261+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=naijasinglesmeet.herokuapp.com request_id=6561ef3b-42df-48a4-a227-6d9aa163b5c9 fwd="41.217.104.185" dyno=web.1 connect=0ms service=1ms status=304 bytes=62 protocol=https
2019-10-08T19:55:41.320556+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#load_avg_1m=0.02
2019-10-08T19:55:41.348659+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#memory_total=79.79MB sample#memory_rss=79.75MB sample#memory_cache=0.04MB sample#memory_swap=0.00MB sample#memory_pgpgin=29231pages sample#memory_pgpgout=8805pages sample#memory_quota=512.00MB
2019-10-08T19:56:02.581435+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#load_avg_1m=0.01
2019-10-08T19:56:02.606547+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#memory_total=79.76MB sample#memory_rss=79.75MB sample#memory_cache=0.01MB sample#memory_swap=0.00MB sample#memory_pgpgin=29231pages sample#memory_pgpgout=8813pages sample#memory_quota=512.00MB
2019-10-08T19:56:22.544894+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#load_avg_1m=0.01
2019-10-08T19:56:22.576747+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#memory_total=79.76MB sample#memory_rss=79.75MB sample#memory_cache=0.01MB sample#memory_swap=0.00MB sample#memory_pgpgin=29231pages sample#memory_pgpgout=8813pages sample#memory_quota=512.00MB
2019-10-08T19:56:43.65213+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#load_avg_1m=0.01 sample#load_avg_5m=0.03
2019-10-08T19:56:43.68744+00:00 heroku[web.1]: source=web.1 dyno=heroku.148955966.114d5aad-5be9-43d4-9b68-1c16025c2349 sample#memory_total=79.76MB sample#memory_rss=79.75MB sample#memory_cache=0.01MB sample#memory_swap=0.00MB sample#memory_pgpgin=29231pages sample#memory_pgpgout=8813pages sample#memory_quota=512.00MB
Hi guys.... Here's an update... finally, I see something come up...
2019-10-08T20:25:08.263845+00:00 app[web.1]: D, [2019-10-08T19:55:38.481415 #4] DEBUG -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] (1.9ms) COMMIT
2019-10-08T20:25:08.263848+00:00 app[web.1]: I, [2019-10-08T19:55:38.492062 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Rendering devise/mailer/confirmation_instructions.html.erb
2019-10-08T20:25:08.26385+00:00 app[web.1]: I, [2019-10-08T19:55:38.494157 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Rendered devise/mailer/confirmation_instructions.html.erb (2.0ms)
2019-10-08T20:25:08.263853+00:00 app[web.1]: D, [2019-10-08T19:55:38.494327 #4] DEBUG -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Devise::Mailer#confirmation_instructions: processed outbound mail in 12.1ms
2019-10-08T20:25:08.263855+00:00 app[web.1]: I, [2019-10-08T19:55:38.494606 #4] INFO -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] Completed 500 Internal Server Error in 195ms (ActiveRecord: 14.8ms)
2019-10-08T20:25:08.263857+00:00 app[web.1]: F, [2019-10-08T19:55:38.496369 #4] FATAL -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67]
2019-10-08T20:25:08.26386+00:00 app[web.1]: F, [2019-10-08T19:55:38.496444 #4] FATAL -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
2019-10-08T20:25:08.263862+00:00 app[web.1]: F, [2019-10-08T19:55:38.496669 #4] FATAL -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] 2:
2019-10-08T20:25:08.263864+00:00 app[web.1]: [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] 3: <p>You can confirm your account email through the link below:</p>
2019-10-08T20:25:08.263866+00:00 app[web.1]: [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] 4:
2019-10-08T20:25:08.263867+00:00 app[web.1]: [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] 5: <p><%= link_to 'Confirm my account', confirmation_url(#resource, confirmation_token: #token) %></p>
2019-10-08T20:25:08.263869+00:00 app[web.1]: F, [2019-10-08T19:55:38.496775 #4] FATAL -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67]
2019-10-08T20:25:08.26387+00:00 app[web.1]: F, [2019-10-08T19:55:38.496845 #4] FATAL -- : [bf3b49db-ec4a-4bde-ae56-c5ae727b5f67] app/views/devise/mailer/confirmation_instructions.html.erb:5:in `_app_views_devise_mailer_confirmation_instructions_html_erb__3272380372352870108_47027054750980'
The relevant part of the error message is the following:
[2019-10-08T19:55:38.492062 #4] Rendering devise/mailer/confirmation_instructions.html.erb
[2019-10-08T19:55:38.496444 #4] FATAL -- :ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
So you mailing template is trying to render, but throws an ActionView::Template::Error and actually tells you the problem:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true)
So you are using a link_to in your email, that one of course has to know the hostname, in order to create a full url. So you need to define that hostname somewhere.
For example you can set it in config/environments/production.rb by including
config.action_controller.default_url_options = {:host => "naijasinglesmeet.herokuapp.com"}
This is because your application does not know under which host/domain it is running, you have to tell it that.
A little tip, if you run into such problems, run heroku logs --tail, this will give you a continous logs as if you were using the development server.

Form works in development but not production - Heroku

I have a voting platform that I'm building for my company and I am very close to finishing it but the actual voting is failing while in production. I've done all my migrating and everything, and it's still working in development.
Here are the logs I'm receiving from heroku:
2019-01-11T18:33:59.235681+00:00 app[web.1]: I,
[2019-01-11T18:33:59.235579 #4] INFO -- :
[772bc37c-00ee-43da-aa81-564d353553bb] Started POST
"/ballots/13/votes" for 75.150.214.2 at 2019-01-11 18:33:59 +0000
2019-01-11T18:33:59.236373+00:00 app[web.1]: I,
[2019-01-11T18:33:59.236296 #4] INFO -- :
[772bc37c-00ee-43da-aa81-564d353553bb] Processing by
VotesController#create as HTML 2019-01-11T18:33:59.236437+00:00
app[web.1]: I, [2019-01-11T18:33:59.236378 #4] INFO -- :
[772bc37c-00ee-43da-aa81-564d353553bb] Parameters: {"utf8"=>"✓",
"authenticity_token"=>"Y/vAh2kYPskozS2yQn3Ky1fOq41abLUjlxho0Q+zXHSndVlaSfwYz7bdoqvintdBXrYNDhsbIduYICpUAx3/0g==",
"user_vote"=>"Why", "vote"=>{"comment"=>""}, "commit"=>"Cast Vote",
"ballot_id"=>"13"} 2019-01-11T18:33:59.239540+00:00 app[web.1]: D,
[2019-01-11T18:33:59.239464 #4] DEBUG -- :
[772bc37c-00ee-43da-aa81-564d353553bb] Ballot Load (0.7ms) SELECT
"ballots".* FROM "ballots" WHERE "ballots"."id" = $1 LIMIT $2 [["id",
13], ["LIMIT", 1]] 2019-01-11T18:33:59.240333+00:00 app[web.1]: I,
[2019-01-11T18:33:59.240244 #4] INFO -- :
[772bc37c-00ee-43da-aa81-564d353553bb] Completed 500 Internal Server
Error in 4ms (ActiveRecord: 0.7ms) 2019-01-11T18:33:59.240846+00:00
app[web.1]: F, [2019-01-11T18:33:59.240770 #4] FATAL -- :
[772bc37c-00ee-43da-aa81-564d353553bb]
2019-01-11T18:33:59.240917+00:00 app[web.1]: F,
[2019-01-11T18:33:59.240847 #4] FATAL -- :
[772bc37c-00ee-43da-aa81-564d353553bb]
ActiveModel::UnknownAttributeError (unknown attribute 'comment' for
Vote.):' '2019-01-11T18:33:59.240981+00:00 app[web.1]: F,
[2019-01-11T18:33:59.240914 #4] FATAL -- :
[772bc37c-00ee-43da-aa81-564d353553bb]
2019-01-11T18:33:59.241051+00:00 app[web.1]: F,
[2019-01-11T18:33:59.240987 #4] FATAL -- :
[772bc37c-00ee-43da-aa81-564d353553bb]
app/controllers/votes_controller.rb:10:in `create'
2019-01-11T18:34:07.533587+00:00 heroku[run.2070]: State changed from
up to complete bobby#bobby-Al
Here's my code for vote create
def create
#ballot = Ballot.find(params[:ballot_id])
#vote = #ballot.votes.new(user_vote: params[:user_vote], comment: params[:vote][:comment])
#vote.user_id = current_user.id
if !current_user.votes.find_by(ballot_id: params[:ballot_id])
#vote.save
redirect_to ballot_path(params[:ballot_id])
else
flash[:alert] = "You've already voted on this ballot"
redirect_to ballot_path(params[:ballot_id])
end
end
It seems like a migration problem, just make sure to run your migrations for the environment production on heroku like this:
heroku run rake db:migrate
Restart your app
heroku restart --app my_app_name
Important
If you generate a migration that creates a table and make a push to heroku, to add another column to that table you shouldn't modify that one, instead you should create another one for that.
When you run rake db:migrate, rails register that on the table schema_migrations, so if you modify a migrate that is already registered is not going to be executed again. This could be the case, check directly on your database and see if the column is there.

Heroku database error on production: PG::UndefinedTable Error

Every time I run the app on Heroku, this is what comes out of the logs:
2018-04-15T22:51:12.806576+00:00 app[web.1]: I, [2018-04-15T22:51:12.806420 #4] INFO -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] Started GET "/patients" for 112.205.217.139 at 2018-04-15 22:51:12 +0000
2018-04-15T22:51:12.808307+00:00 app[web.1]: I, [2018-04-15T22:51:12.808235 #4] INFO -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] Processing by PatientsController#index as HTML
2018-04-15T22:51:12.811835+00:00 app[web.1]: I, [2018-04-15T22:51:12.811756 #4] INFO -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] Rendering patients/index.html.erb within layouts/application
2018-04-15T22:51:15.563600+00:00 heroku[router]: at=info method=GET path="/patients" host=jdent-patrec.herokuapp.com request_id=cd1ed367-c720-4568-ac03-a3b1bec4fc1b fwd="112.205.217.139" dyno=web.1 connect=0ms service=2757ms status=500 bytes=1827 protocol=https
2018-04-15T22:51:15.557887+00:00 app[web.1]: D, [2018-04-15T22:51:15.557726 #4] DEBUG -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] [1m[36mPatient Load (2.7ms)[0m [1m[34mSELECT "patients".* FROM "patients"[0m
2018-04-15T22:51:15.558988+00:00 app[web.1]: I, [2018-04-15T22:51:15.558899 #4] INFO -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] Rendered patients/index.html.erb within layouts/application (2747.0ms)
2018-04-15T22:51:15.559386+00:00 app[web.1]: I, [2018-04-15T22:51:15.559271 #4] INFO -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] Completed 500 Internal Server Error in 2751ms (ActiveRecord: 2589.2ms)
2018-04-15T22:51:15.560650+00:00 app[web.1]: F, [2018-04-15T22:51:15.560581 #4] FATAL -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b]
2018-04-15T22:51:15.560736+00:00 app[web.1]: F, [2018-04-15T22:51:15.560661 #4] FATAL -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "patients" does not exist
2018-04-15T22:51:15.560739+00:00 app[web.1]: LINE 1: SELECT "patients".* FROM "patients"
2018-04-15T22:51:15.560741+00:00 app[web.1]: ^
2018-04-15T22:51:15.560742+00:00 app[web.1]: : SELECT "patients".* FROM "patients"):
2018-04-15T22:51:15.561063+00:00 app[web.1]: F, [2018-04-15T22:51:15.560972 #4] FATAL -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 22: </thead>
2018-04-15T22:51:15.561066+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 23:
2018-04-15T22:51:15.561067+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 24: <tbody>
2018-04-15T22:51:15.561069+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 25: <% #patients.each do |patient| %>
2018-04-15T22:51:15.561071+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 26: <tr>
2018-04-15T22:51:15.561072+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 27: <td><%= patient.id %></td>
2018-04-15T22:51:15.561074+00:00 app[web.1]: [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] 28: <td><%= patient.first_name %></td>
2018-04-15T22:51:15.561133+00:00 app[web.1]: F, [2018-04-15T22:51:15.561061 #4] FATAL -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b]
2018-04-15T22:51:15.561200+00:00 app[web.1]: F, [2018-04-15T22:51:15.561139 #4] FATAL -- : [cd1ed367-c720-4568-ac03-a3b1bec4fc1b] app/views/patients/index.html.erb:25:in `_app_views_patients_index_html_erb___2618543925626266733_38249580'
Error pic:
I've been trying to look for the problem for days but to no avail.
Did you recently create this table? If so, try
heroku run rails db:migrate

Heroku Build Successful, but " We're sorry, but something went wrong."

Any help would be appreciated.
Still pretty new to ruby on rails. I probably can't spot my errors.
So my code works on my localhost and I can successfully deploy to heroku. However when try to access the website, the message "We're sorry..." pops up instead of my actual website.
My heroku Logs:
2018-04-03T12:26:06.139264+00:00 app[web.1]: I, [2018-04-03T12:26:06.139156 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Started GET "/" for 66.183.97.241 at 2018-04-03 12:26:06 +0000
2018-04-03T12:26:06.152951+00:00 app[web.1]: I, [2018-04-03T12:26:06.152879 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Rendering home/index.html.erb within layouts/application
2018-04-03T12:26:06.154713+00:00 app[web.1]: I, [2018-04-03T12:26:06.154638 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Rendered home/_w-menu.html.erb (0.3ms)
2018-04-03T12:26:06.155577+00:00 app[web.1]: I, [2018-04-03T12:26:06.155519 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Rendered home/_header.html.erb (0.3ms)
2018-04-03T12:26:06.143890+00:00 app[web.1]: I, [2018-04-03T12:26:06.143817 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Processing by HomeController#index as HTML
2018-04-03T12:26:06.156571+00:00 app[web.1]: I, [2018-04-03T12:26:06.156473 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Rendered home/index.html.erb within layouts/application (3.4ms)
2018-04-03T12:26:06.156791+00:00 app[web.1]: I, [2018-04-03T12:26:06.156734 #4] INFO -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] Completed 500 Internal Server Error in 13ms
2018-04-03T12:26:06.157513+00:00 app[web.1]: F, [2018-04-03T12:26:06.157437 #4] FATAL -- : [37787d0f-6494-4e06-9b18-d8ecd9129051]
2018-04-03T12:26:06.157592+00:00 app[web.1]: F, [2018-04-03T12:26:06.157522 #4] FATAL -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] ActionView::Template::Error (The asset "Events.jpeg" is not present in the asset pipeline.):
2018-04-03T12:26:06.157831+00:00 app[web.1]: F, [2018-04-03T12:26:06.157756 #4] FATAL -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] 53: <h1 class="index-titles">Recent Events</h1>
2018-04-03T12:26:06.157839+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 55: <p class="index-content"><strong>Date:</strong> 7:00 PM, ********* 1st | <strong>Location:</strong> ****** *****</p>
2018-04-03T12:26:06.157835+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 54: <h1 class="index-subtitles">**** *th Annual ******* Concert——————————————————</h1>
2018-04-03T12:26:06.157841+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 56: <%= image_tag "Events.jpeg", :style => "display: block; margin: auto; margin-top: 2%; border: 10px solid #E51D39; border-radius: 5%; height: 700px; width: auto;" %>
2018-04-03T12:26:06.157843+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 58: </div>
2018-04-03T12:26:06.157842+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 57: <p class="index-content" style="text-align: center; color: white;"><strong><font size="7em">~ Thank You To All Who Showed Up ~<br>Special Thanks to ****</font></strong></p>
2018-04-03T12:26:06.157845+00:00 app[web.1]: [37787d0f-6494-4e06-9b18-d8ecd9129051] 59:
2018-04-03T12:26:06.157896+00:00 app[web.1]: F, [2018-04-03T12:26:06.157838 #4] FATAL -- : [37787d0f-6494-4e06-9b18-d8ecd9129051]
2018-04-03T12:26:06.157985+00:00 app[web.1]: F, [2018-04-03T12:26:06.157912 #4] FATAL -- : [37787d0f-6494-4e06-9b18-d8ecd9129051] app/views/home/index.html.erb:56:in `_app_views_home_index_html_erb___229626976587277798_32272960'
Thank you!
You can not hold pictures in Heroku. Although you managed to place them there, they will disappear.
You can use AWS S3 to store static assets.
https://devcenter.heroku.com/articles/s3
...or if you don't have credit card ( it is necessary for registration ) try use dropbox.

Heroku 'redirected to' in log doesn't match the URL that it actually redirects to

I've just deployed my Ruby app to Heroku and the redirect_to in my contacts_controller.rb no longer works. If I run the local server, it works fine but on Heroku, it takes me to a URL that doesn't exist so I get an error message.
I've had a look at the Heroku log and even there, it says it's redirecting to the correct URL but that doesn't match what it does in the app.
I've tried restarting Heroku. I've searched through the documentation to see if there is a way to manually change the path because I noticed at one point in the log, it says it's pushing to '/contacts' which is the incorrect URL that gives me the error but I now think that's referencing the db, not the redirect URL.
What's odd is the redirect_to path is the same for success or failure in my if/else method and it works fine for the failure but not success.
contacts_controller.rb file:
class ContactsController < ApplicationController
def new
#contact = Contact.new
end
def create
#contact = Contact.new(contact_params)
if #contact.save
redirect_to new_contact_path
name = params[:contact][:name]
email = params[:contact][:email]
body = params[:contact][:comments]
ContactMailer.contact_email(name, email, body).deliver
flash[:success] = "Message sent."
else
flash[:danger] = #contact.errors.full_messages.join(", ")
redirect_to new_contact_path
end
end
private
def contact_params
params.require(:contact).permit(:name, :email, :comments)
end
end
Here's the heroku log once I've submitted my contact form:
2017-03-02T12:15:00.498443+00:00 app[web.1]: I, [2017-03-02T12:15:00.498389 #4] INFO -- : [] Redirected to https://myapp.herokuapp.com/contact-us
2017-03-02T12:15:00.506175+00:00 app[web.1]: I, [2017-03-02T12:15:00.506104 #4] INFO -- : [] Rendering contact_mailer/contact_email.html.erb
2017-03-02T12:15:00.506925+00:00 app[web.1]: I, [2017-03-02T12:15:00.506848 #4] INFO -- : [] Rendered contact_mailer/contact_email.html.erb (0.6ms)
2017-03-02T12:15:00.793142+00:00 app[web.1]: I, [2017-03-02T12:15:00.793082 #4] INFO -- : [] Sent mail to xxxxxxxx#xxxx.xxx (6.6ms)
2017-03-02T12:15:00.786369+00:00 app[web.1]: D, [2017-03-02T12:15:00.786255 #4] DEBUG -- : [] ContactMailer#contact_email: processed outbound mail in 286.1ms
2017-03-02T12:15:00.793195+00:00 app[web.1]: D, [2017-03-02T12:15:00.793141 #4] DEBUG -- : [] Date: Thu, 02 Mar 2017 12:15:00 +0000
2017-03-02T12:15:00.793197+00:00 app[web.1]: From: is
2017-03-02T12:15:00.793197+00:00 app[web.1]: To: xxxxx#xxx.xxx
2017-03-02T12:15:00.793198+00:00 app[web.1]: Message-ID: <xxxx.mail>
2017-03-02T12:15:00.793199+00:00 app[web.1]: Subject: Contact Form Message
2017-03-02T12:15:00.793200+00:00 app[web.1]: Mime-Version: 1.0
2017-03-02T12:15:00.793200+00:00 app[web.1]: Content-Type: text/html;
2017-03-02T12:15:00.793201+00:00 app[web.1]: charset=UTF-8
2017-03-02T12:15:00.793201+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2017-03-02T12:15:00.793202+00:00 app[web.1]: <!DOCTYPE html>
2017-03-02T12:15:00.793202+00:00 app[web.1]:
2017-03-02T12:15:00.793203+00:00 app[web.1]: <html>
2017-03-02T12:15:00.793204+00:00 app[web.1]: <head></head>
2017-03-02T12:15:00.793204+00:00 app[web.1]: <body>
2017-03-02T12:15:00.793205+00:00 app[web.1]: <p>You have received a message from the site's contact form, from
2017-03-02T12:15:00.793206+00:00 app[web.1]: this, is.</p>
2017-03-02T12:15:00.793207+00:00 app[web.1]: <p>frustrating</p>
2017-03-02T12:15:00.793208+00:00 app[web.1]: </body>
2017-03-02T12:15:00.793208+00:00 app[web.1]: </html>
2017-03-02T12:15:00.793409+00:00 app[web.1]: I, [2017-03-02T12:15:00.793333 #4] INFO -- : [] Completed 500 Internal Server Error in 305ms (ActiveRecord: 3.8ms)
2017-03-02T12:15:00.793869+00:00 app[web.1]: F, [2017-03-02T12:15:00.793819 #4] FATAL -- : []
2017-03-02T12:15:00.793910+00:00 app[web.1]: F, [2017-03-02T12:15:00.793871 #4] FATAL -- : [] Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
2017-03-02T12:15:00.793958+00:00 app[web.1]: F, [2017-03-02T12:15:00.793909 #4] FATAL -- : []
2017-03-02T12:15:00.793979+00:00 app[web.1]: F, [2017-03-02T12:15:00.793943 #4] FATAL -- : [] app/controllers/contacts_controller.rb:13:in `create'
2017-03-02T12:15:00.794339+00:00 heroku[router]: at=info method=POST path="/contacts" host=myapp.herokuapp.com request_id=25154829-90fe-44c4-a715-eaf9a6fd83d1 fwd="87.114.208.14" dyno=web.1 connect=1ms service=313ms status=500 bytes=1669
And the actual link that it redirects me to is https://myapp.herokuapp.com/contacts
Error message on screen: "We're sorry, but something went wrong.
If you are the application owner check the logs for more information."
I have a feeling it might be something to do with my db but I have no idea why it's redirecting to that link. The db that I've migrated to Heroku is called 'contacts'
Really appreciate any suggestions, thank you.
Your issue seems to be with email delivery, not redirecting. If you take a look again at your log, you will see the following lines:
2017-03-02T12:15:00.793409+00:00 app[web.1]: I, [2017-03-02T12:15:00.793333 #4] INFO -- : [] Completed 500 Internal Server Error in 305ms (ActiveRecord: 3.8ms)
2017-03-02T12:15:00.793869+00:00 app[web.1]: F, [2017-03-02T12:15:00.793819 #4] FATAL -- : []
2017-03-02T12:15:00.793910+00:00 app[web.1]: F, [2017-03-02T12:15:00.793871 #4] FATAL -- : [] Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
Your application is returning a 500 error, and the error message shown in the log indicates an issue with email delivery (email via SMTP uses port 25).
Do you have an email add-on installed and configured for your Heroku account and attached to your app? There are several listed on Heroku's website: https://elements.heroku.com/addons/categories/email-sms
I suspect this is working as intended locally because you are running software such as postfix, but this is not present on Heroku out-of-the-box.

Resources