Forum: Ruby on Rails Change the default folder for image_tag, javascript_include_

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-01-06 22:13
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
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-01-07 00:53
(Received via mailing list)
> 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
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-01-07 11:41
> 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 topic is locked and can not be replied to.