# Change the default folder for image\_tag, javascript\_include\_

**URL:** <https://www.ruby-forum.com/t/change-the-default-folder-for-image-tag-javascript-include/157052>\
**Category:** Rails\
**Created:** [January 6, 2009, 10:13pm UTC](https://www.ruby-forum.com/t/change-the-default-folder-for-image-tag-javascript-include/157052 "2009-01-06T22:13:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [January 6, 2009, 10:13pm UTC](https://www.ruby-forum.com/t/change-the-default-folder-for-image-tag-javascript-include/157052/1 "2009-01-06T22:13:19Z")

</div>

Hi,

I don’t want my default folder to be [mysite.com/images/logo.png](http://mysite.com/images/logo.png), but  
instead [mysite.com/common/images/logo.png](http://mysite.com/common/images/logo.png)

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

Thanks

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [January 7, 2009, 12:53am UTC](https://www.ruby-forum.com/t/change-the-default-folder-for-image-tag-javascript-include/157052/2 "2009-01-07T00:53:29Z")

</div>

> I don’t want my default folder to be [mysite.com/images/logo.png](http://mysite.com/images/logo.png), but  
> instead [mysite.com/common/images/logo.png](http://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

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [January 7, 2009, 11:41am UTC](https://www.ruby-forum.com/t/change-the-default-folder-for-image-tag-javascript-include/157052/3 "2009-01-07T11:41:32Z")

</div>

> 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.
