Geoffrey Hug Geoffrey Hug - 1 month ago 13
Apache Configuration Question

Impossible to serve generated images without restarting app with Rails + Passenger?

I have images that are generated by users and written to

public/designer/designer_output
folder.

In
config/environments/production.rb
I have

config.serve_static_files = true
config.assets.compile = true


In
config/initializers/assets.rb
I have

Rails.application.config.assets.paths << Rails.root.join('public', 'designer', 'designer_output')


Yet I can't access the files either by requesting
/assets/file_name
nor
/public/designer/designer_output/file_name


If I restart the server then the files become available only via the
/assets/
path. But I need them to be available as soon as they are created without restarting.

If find it odd that I can't access them through the public folder at all.

This is on Rails 4.2.6 with Apache/Passenger

Also I have carrierwave as an upload gem, and it is storing files in public/uploads folder and that works fine.

max max
Answer

The public folder is used as the web root for the rails server. You need to drop public in the path or URL:

<!-- file is at /public/foo/bar.png --!>
<img src="/foo/bar.png" />
Comments