2

When in development env it is working fine, but when I run the app in production evn, it says We're sorry, but something went wrong. If you are the application owner check the logs for more information.

The production log says:

I, [2020-04-21T19:25:25.667458 #31504]  INFO -- : [74b45073-2b93-4d6e-8d02-346cf6c72631] Started GET "/" for 127.0.0.1 at 2020-04-21 19:25:25 +0530
I, [2020-04-21T19:25:25.668742 #31504]  INFO -- : [74b45073-2b93-4d6e-8d02-346cf6c72631] Processing by DashboardController#home as HTML
I, [2020-04-21T19:25:25.670973 #31504]  INFO -- : [74b45073-2b93-4d6e-8d02-346cf6c72631]   Rendering dashboard/home.html.haml within layouts/application
I, [2020-04-21T19:25:25.671255 #31504]  INFO -- : [74b45073-2b93-4d6e-8d02-346cf6c72631]   Rendered dashboard/home.html.haml within layouts/application (Duration: 0.1ms | Allocations: 15)
I, [2020-04-21T19:25:25.672210 #31504]  INFO -- : [74b45073-2b93-4d6e-8d02-346cf6c72631] Completed 500 Internal Server Error in 3ms (Allocations: 1237)
F, [2020-04-21T19:25:25.673501 #31504] FATAL -- : [74b45073-2b93-4d6e-8d02-346cf6c72631]   
[74b45073-2b93-4d6e-8d02-346cf6c72631] ActionView::Template::Error (Webpacker can't find application in /home/zamir/rails_studio/sunrise/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
  "application.js": "/packs/js/application-fafdbfed632f089e407b.js",
  "application.js.map": "/packs/js/application-fafdbfed632f089e407b.js.map",
  "entrypoints": {
    "application": {
      "js": [
        "/packs/js/application-fafdbfed632f089e407b.js"
      ],
      "js.map": [
        "/packs/js/application-fafdbfed632f089e407b.js.map"
      ]
    }
  }
}
):
[74b45073-2b93-4d6e-8d02-346cf6c72631]      6:       = controller.page_title
[74b45073-2b93-4d6e-8d02-346cf6c72631]      7:     = csrf_meta_tags
[74b45073-2b93-4d6e-8d02-346cf6c72631]      8:     = csp_meta_tag
[74b45073-2b93-4d6e-8d02-346cf6c72631]      9:     = stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
[74b45073-2b93-4d6e-8d02-346cf6c72631]     10:     = javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
[74b45073-2b93-4d6e-8d02-346cf6c72631]     11:   %body
[74b45073-2b93-4d6e-8d02-346cf6c72631]     12:     .container-fluid
[74b45073-2b93-4d6e-8d02-346cf6c72631]   
[74b45073-2b93-4d6e-8d02-346cf6c72631] app/views/layouts/application.html.haml:9
I, [2020-04-21T19:25:25.988388 #31504]  INFO -- : [6a573ad4-9775-4565-8f2e-e32395e409cd] Started GET "/favicon.ico" for 127.0.0.1 at 2020-04-21 19:25:25 +0530
F, [2020-04-21T19:25:25.989343 #31504] FATAL -- : [6a573ad4-9775-4565-8f2e-e32395e409cd]   
[6a573ad4-9775-4565-8f2e-e32395e409cd] ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
Zamir Manihar
  • 121
  • 12

3 Answers3

4

I guess the problem is in the production.rb configuration file: you should allow Puma to serve static files.

In production servers, static files are usually served by Nginx, but that's not the case if you run Puma on your local machine.

In order to do so, in your production.rb set this value to true (or create an ENV variable named RAILS_SERVE_STATIC_FILES):

config.public_file_server.enabled = true

Sabre
  • 419
  • 4
  • 12
1

Add gem rails_12factor to your Gemfile. This will add error logging and the ability for your app to serve static assets.

Remember to clobber your assets

RAILS_ENV=production rails assets:clobber RAILS_ENV=production rails assets:precompile

Ahmad
  • 1,497
  • 2
  • 9
  • 16
0

In config/webpacker.yml make extract_css option true for production:

extract_css: true

Then run the following command before starting the server in production mode:

RAILS_ENV=production rails assets:precompile
Karoid
  • 750
  • 4
  • 17