Skip to content
accelerando

How to change the image assets path in Rails

I found no other way to change the path of “images” in a Rails application than monkey patching the AssetTagHelper like so:

module ActionView
  module Helpers #:nodoc:
    module AssetTagHelper
      def image_path(source)
        compute_public_path(source, 'static_images')
      end
      alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
    end
  end
end

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

*

Close
E-mail It