Resource Access Path from Rails Controller

I use the client part of the yml configuration file, configuration, which I also need to load on the server side, I placed it inside app / assets / javascripts / configuration.yml

I can use # {asset_path 'configuration.yml'} inside the view to get the path, but I cannot enter the controller. I could access it directly using "# Rails.root" /app/assets/javascripts/configuration.yml ", but when the file name is expanded, a digest line is added.

How can I get the same path from the controller?

+58
ruby-on-rails sprockets
Oct. 19 '11 at 19:36
source share
1 answer
ActionController::Base.helpers.asset_path("configuration.yml") 

It may also be useful to add config.yml to a different folder to separate javascript from files other than javascript.

+97
Oct 19 '11 at 20:13
source share



All Articles