0

Anything works fine while I run my server using rails s, but while I run the server in production mode it looks like:without stylesheets and other assets. What I have to do to solve that problem?

3 Answers3

4

In production.rb set

config.public_file_server.enabled = true
config.assets.compile = true

Then run the server like this

RAILS_ENV=production rails assets:precompile
RAILS_ENV=production rails server
reiallenramos
  • 1,235
  • 2
  • 21
  • 29
  • Enabling only `config.public_file_server.enabled = true` worked for me. Also enabling `config.assets.compile = true` is not recommended in the production environment. Ref: (https://stackoverflow.com/questions/42545262/rails-5-assets-not-loading-in-production) – Karthik K May 08 '20 at 08:38
0

Did you precompile your assets? Try running locally:

RAILS_ENV=production bundle exec rake assets:precompile

A public/assets directory will be created and then commit changes to your repository. The assets should now be detected on your production server.

John Baker
  • 2,315
  • 13
  • 12
0

Can you provide us with an example how you are linking to CSS and JS files? It should look like this ( this is in .haml not .erb)

= stylesheet_link_tag 'default/application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true

Jameson
  • 1
  • 2
  • 1