Reputation: 188
I'm having issues serving static files from my Asset pipeline using Rails 5 on Heroku. I have looked at other questions but none seem to resolve the issue.
I get HomeController#index is missing a template for this request format and variant. request.formats: ["image/png"] request.variant: []
my config/production.rb
config.assets.compile = false
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Upvotes: 2
Views: 892
Reputation: 2244
Compiling assets locally is not a good practice and should be avoided as artifacts should not be in version control. I was having the same issue while attempting to set a background image using sass and using the image-url
helper generates the correct url.
background: image-url('my-image.png') no-repeat center;
For image tags and erb css templates there is the image_path
and image_tag
rails helpers.
Upvotes: 0
Reputation: 4427
Compile all assets locally and push to heroku.
Try following steps:
change line in config/environments/production.rb
config.assets.compile = true
Run commands:
RAILS_ENV=production rake assets:precompile
push all compile assets with manifest.rb to heroku
.
Upvotes: 2