1

My rails app (v 5.2.4.1) works perfectly in local with config.assets.compile = true. All the assets (images, js etc) are correctly loaded. It works too in production with the same config (but it's very slow...)

So i read here config.assets.compile=true in Rails production, why not? that it's a better way so set config.assets.compile = false in production

config.assets.compile = false    
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')    

config.assets.css_compressor = :sass
config.assets.debug = false
config.assets.digest = true  
config.public_file_server.enabled = true

After set to false I made this command RAILS_ENV=production rake assets:precompile (all the assets are generated in public/assets on Heroku)

i restart the server but all images are lost and .js are not loaded ?

Where is my mistake ?

Teetof
  • 87
  • 2
  • 6
  • Your misstake is bad research. You don't have to do anything on heroku. You just push and heroku will precompile your assets and they will be statically served without going through your rails app. Refer to to the [actual heroku documentation](https://devcenter.heroku.com/articles/getting-started-with-rails5#rails-asset-pipeline) instead of a SO question from 2012. – max Feb 17 '20 at 20:42
  • From HerokuDevCenter (Last update December 2018) https://devcenter.heroku.com/articles/rails-asset-pipeline#compile-set-to-true-in-production. It's clear, when deploy to Heroku you havet to set config.assets.compile = false (because your app runs very slow). – Teetof Feb 18 '20 at 07:44
  • That's article is for rails 3 & 4. The assets pipeline was changed substantially in Rails 5. – max Feb 18 '20 at 08:36
  • Ok Max, so i set config.assets.compile = true in my production.rb ? If i set to true i have this warning during deploy to Heroku remote: ###### WARNING: remote: remote: You set your `config.assets.compile = true` in production. remote: This can negatively impact the performance of your application. remote: remote: For more information can be found in this article: remote: https://devcenter.heroku.com/articles/rails-asset-pipeline#compile-set-to-true-in-production – Teetof Feb 18 '20 at 10:02
  • I'm not saying you should set it to true. I'm saying that rails 5 defaults to false in production and that you don't have to do any configuration like you did in 3/4. Just axe that junk and push. – max Feb 18 '20 at 10:46
  • 1
    Mmm...Ok I just let the default's false in production. Yes indeed i do not have the Warning message ... but I loose my images and the .js files are not loaded ! When i read the logs : [2020-02-18T10:38:31.651914 #4] FATAL -- : [88de871b-28be-4551-aead-88951d222f61] ActionController::RoutingError (No route matches [GET] "/assets/card.js")... or ... [2020-02-18T10:38:31.849253 #4] FATAL -- : [f425ac92-d28e-4482-8ed0-d78bcccaff98] ActionController::RoutingError (No route matches [GET] "/assets/user_3.jpg"). It seem's the Assets are not loaded... – Teetof Feb 18 '20 at 12:19

0 Answers0