asset pipeline - How do I call images in a subdirectory? Rails 4 app breaks when I push to production -


i have rails app performs fine in development push production breaks. working fine until added /gifs subdirectory /images directory.

i'm pulling random gif in directory , displaying it.

<%= image_tag "assets/gifs/#{rand(10)}.gif" %> 

i've tried

<%= image_tag "gifs/#{rand(10)}.gif" %> 

and

<%= asset_url("gifs/#{rand(10)}.gif") %> 

but nothing working. how should structure this?

have tried /assets? this:

<%= image_tag "/assets/gifs/#{rand(10)}.gif" %> 

i start without interpolation make sure can see image , add variable.

edit: sorry quick shot, have in mine , thought might fix it. think need tell config/environments/production.rb want precompile folders also... in development, happily include you, in production, needs more selective , rigid (there various explanations elsewhere).

try this: open config/

look line: config.assets.precompile , add subfolder it.

config.assets.precompile += [ 'gifs/*.gif'] 

if decided organize other assets controller-related subfolders (i that), need add here too: (example: local, resources, projects, shared subfolders)

config.assets.precompile += [ 'local/*.css', 'resources/*.js', 'projects/*.js', 'shared/*.js', 'ui/*.js', 'admin.a    pp.js', 'jquery.tablesorter.min.js', 'date-picker.js', 'date_extras.js', 'jquery.tablesorter.min.js'] 

hope helps!


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -