How can I add my custom methods to my assets such as css files like Rails did with ‘asset_path’ helper?
With Rail’s own helper, I can write this:
# some.css.erb:
<%= asset_path 'a_image.png' %>
# How can I write this:
<%= my_custom_method 'a_image.png' %>
I’ve tried many ways but couldn’t found a decent way to this. Do you know one?
Thanks
The best way I found was to create a custom helper module in app/helpers:
And then to require it like this in application.rb, after your applications configuration (very bottom):
And you might follow this issue to find a better way: https://github.com/rails/rails/issues/3282