Change the default folder for image_tag, javascript_include_

Hi,

I don’t want my default folder to be mysite.com/images/logo.png, but
instead mysite.com/common/images/logo.png

How can I change that? Same applies to stylesheets and javascripts.

Thanks

I don’t want my default folder to be mysite.com/images/logo.png, but
instead mysite.com/common/images/logo.png

How can I change that? Same applies to stylesheets and javascripts.

Don’t know if there’s an official way, but you could monkey patch some
of the methods…

Look at actionpack/lib/action_view/helpers/asset_tag_helper.rb… and
override these methods:

def compute_javascript_paths(*args)
expand_javascript_sources(*args).collect { |source|
compute_public_path(source, ‘javascripts’, ‘js’, false) }
end

def compute_stylesheet_paths(*args)
expand_stylesheet_sources(*args).collect { |source|
compute_public_path(source, ‘stylesheets’, ‘css’, false) }
end

def image_path(source)
compute_public_path(source, ‘images’)
end

-philip

Don’t know if there’s an official way, but you could monkey patch some
of the methods…

Hi Phil,

I know that we can set an assert server, and I think that one day I also
bumped into changing the default folder (I might be wrong), but I cannot
find that piece of information again, so I cannot confirm.

I would rather not start monkey patching for such a simple problem,
otherwise i can simply add the “absolute” path for the assets, but the
line is getting long.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs