# Images urls

**URL:** <https://www.ruby-forum.com/t/images-urls/75176>\
**Category:** Rails\
**Created:** [November 8, 2006, 12:51am UTC](https://www.ruby-forum.com/t/images-urls/75176 "2006-11-08T00:51:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [November 8, 2006, 12:51am UTC](https://www.ruby-forum.com/t/images-urls/75176/1 "2006-11-08T00:51:24Z")

</div>

Hi you all,

I have this piece of code in my local application:

link\_to\_image “category”, {:action =\> “list\_by\_category”}â€¦

This worked fine because I have my WEBrick server  
([http://localhost:3000](http://localhost:3000))  
and that image pointed to “/images/category.png”, which was equal to  
“localhost:3000/images/category.png”.

However, I’ve just uploaded my application to a server, under a  
directory called “ToDo” (yes, it’s the 4daysOnRails app :D).  
Here the image does not work, cause is referring to  
“[mydomain.com/images/category.png](http://mydomain.com/images/category.png)”, and the image is really located at  
“[mydomain.com/ToDo/images/category.png](http://mydomain.com/ToDo/images/category.png)” (under the specific “ToDo”  
directory).  
I’ve just changed that in the uploaded app (link\_to\_image  
“/ToDo/public/images/category”) but, how can I put the link so it works  
at both places?

Thanks a lot.  
PT: I’ve seen the url\_for stuff, but I don’t know how to use it with  
this…

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [November 8, 2006, 9:39am UTC](https://www.ruby-forum.com/t/images-urls/75176/2 "2006-11-08T09:39:02Z")

</div>

Damaris F. wrote:

> However, I’ve just uploaded my application to a server, under a  
> directory called “ToDo” (yes, it’s the 4daysOnRails app :D).  
> Here the image does not work, cause is referring to  
> “[mydomain.com/images/category.png](http://mydomain.com/images/category.png)”, and the image is really located at  
> “[mydomain.com/ToDo/images/category.png](http://mydomain.com/ToDo/images/category.png)” (under the specific “ToDo”  
> directory).  
> I’ve just changed that in the uploaded app (link\_to\_image  
> “/ToDo/public/images/category”) but, how can I put the link so it works  
> at both places?
> 
> Thanks a lot.  
> PT: I’ve seen the url\_for stuff, but I don’t know how to use it with  
> this…

Rails uses urls form the root of the domain frequently since the routes  
create what look directory and confuse browsers using relative urls  
looking for assets.

Try to install your on a subdomain rather than just a subfolder. Also  
be very careful that your config/database.yml is not publically  
accessible or you could find your entire database hacked one day.

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [November 8, 2006, 9:49am UTC](https://www.ruby-forum.com/t/images-urls/75176/3 "2006-11-08T09:49:13Z")

</div>

I think whant you want to do is set the asset\_host configuration  
parameter for production mode to “/ToDo”  
You might need to be wary of [http://dev.rubyonrails.org/ticket/5406](http://dev.rubyonrails.org/ticket/5406)

Fred

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [November 8, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/images-urls/75176/4 "2006-11-08T22:41:51Z")

</div>

Frederick C. wrote:

> I think whant you want to do is set the asset\_host configuration  
> parameter for production mode to “/ToDo”  
> You might need to be wary of [http://dev.rubyonrails.org/ticket/5406](http://dev.rubyonrails.org/ticket/5406)
> 
> Fred

I would try to change the production.rb to set the appropiate asset,  
cause the server is not mine and I don’t think they give me a subdomain.  
However, I don’t really know how Rails set the URL’s, cause:  
1: controllers and actions in the controllers are set correctly:  
/ToDo/items/…, not /items…  
2: Style sheets are also in the public directory but Rails get them  
correctly (/ToDo/public/stylesheets/…, not /public/stylesheets… )

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [November 12, 2006, 1:13am UTC](https://www.ruby-forum.com/t/images-urls/75176/5 "2006-11-12T01:13:22Z")

</div>

Damaris F. wrote:

> Frederick C. wrote:
> 
> > I think whant you want to do is set the asset\_host configuration  
> > parameter for production mode to “/ToDo”  
> > You might need to be wary of [http://dev.rubyonrails.org/ticket/5406](http://dev.rubyonrails.org/ticket/5406)

Hi you all, after changing the asset in environment/production.rb (to  
"config.action\_controller.asset\_host = “/ToDo” ") something strange  
(for a newbie like me) has ocurred:

– With stylesheets: Before the change, the url Rails applied to the CSS  
was right: ToDo/public/stylesheets/todo.css. After the change is  
ToDo/ToDo/publicâ€¦ so it does not work

– With images (which was my initial problem):â€¦nothing has happened! The  
url is still /images/image.pngâ€¦

What can I do? ☹
