How to change the image assets path in Rails

November 1, 2009 by Michael

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

No comments yet

Post a Comment

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