0

I'm running a Rails 4 app on a DreamHost shared server using FastCGI, and I can't seem to get assets working properly.

Precompile will work to compile application.css.scss, but image-url and asset-url links do not changes to the correct values (ex. url(/assets/images/image-{digest}.png).

I've heard that you can change it to .css.scss.erb and use <%= image_tag "image.png" %>, but I'd rather not change every single link in the file if I can help it.

Am I missing something? I'm running

bundle exec rake assets:precompile RAILS_ENV=production and I have in production.rb

config.assets.compile = false
config.assets.digest = true

What haven't I done yet?

justindao
  • 2,273
  • 4
  • 18
  • 34

2 Answers2

0

It was just a matter of setting

config.serve_static_assets = true

in production.rb, and rerunning

bundle exec rake assets:precompile RAILS_ENV=production

Found at: Image urls for Rails 4 + Less not including the hash

Community
  • 1
  • 1
justindao
  • 2,273
  • 4
  • 18
  • 34
0

I got this warning message in rails-4.2.2: "DEPRECATION WARNING: The configuration option config.serve_static_assets has been renamed to config.serve_static_files to clarify its role (it merely enables serving everything in the public folder and is unrelated to the asset pipeline). The serve_static_assets alias will be removed in Rails 5.0. Please migrate your configuration files accordingly."

This was the line created by default with my app. You should use static_files instead.

config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

I found Rails 4: assets not loading in production and added config.assets.precompile = ['*.js', '*.css', '*.css.erb'] so you should be able to have something like

config.assets.precompile =  ['*.png', '*.js', '*.css', '*.css.erb']

Just add the file type to the array

Community
  • 1
  • 1
Daniel
  • 2,950
  • 2
  • 25
  • 45