ruby on rails - AssetTagHelper::image_path outside views -


It is believed, ActionController :: base.helpers proxy for accessing helpers outside of ideas Works like. Although many of the defined methods rely on controller variables and I am unable to successfully call:

  ActionController :: Base.helpers.image_path ("my_image.png") & gt; & Gt; TypeError exception: string can not be changed in  

See compute_asset_host method config.asset_host but < Code> config is zero .

How can I successfully call image_path from the outside?

Use view_context to access these helpful methods.

You can call the image_path from the controller this way.

  view_context.image_path "my_image.png"  

Comments