开发者

Rails - How would I get the URL of a single image asset in the controller?

开发者 https://www.devze.com 2023-03-07 23:46 出处:网络
I\'ve tried including ActionView::Helpers::AssetTagHelper and then using the image_path() method however it gives me grief:

I've tried including ActionView::Helpers::AssetTagHelper and then using the image_path() method however it gives me grief:

undefined local variable or meth开发者_开发技巧od `config' for ActionView::Helpers::AssetTagHelper:Module

There's probably something simple I'm missing. Any ideas?


I found the solution in Barlow's answer here: How can I use image_path inside Rails 3 Controller

view_context.image_path('/path/to/image')

seems to work for me, no need to include helpers in the Controller

0

精彩评论

暂无评论...
验证码 换一张
取 消