Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 - Asset Pipeline path is 'images/file.jpg' instead of 'assets/file.jpg' [duplicate]

I'm sharing a configuration yml file client side, that I need to also load on the server side, I've placed it inside app/assets/javascripts/configuration.yml

I can use #{asset_path 'configuration.yml'} inside a view to get the path, but I can't inside a controller. I could access directly using "#{Rails.root}/app/assets/javascripts/configuration.yml" but when deploying the filename gets the digest string appended.

How can I get the same path from a controller?

like image 614
Marcel M. Avatar asked Nov 24 '22 12:11

Marcel M.


1 Answers

ActionController::Base.helpers.asset_path("configuration.yml")

Might also be good to put configuration.yml in a different folder to separate javascript from non-javascript files.

like image 149
Artem Kalinchuk Avatar answered Nov 26 '22 03:11

Artem Kalinchuk