Forum: Ruby on Rails First RoR Aplication - images/css paths

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.
Quijote70 (Guest)
on 2009-05-11 12:29
(Received via mailing list)
I routed the page

www.site.com to a controller "welcome"

config/routes.rb: map.root :controller => "welcome"

after this action

the home page

http://www.site.com ho reads the action index works fine

but if I call

http://www.site.com/welcome/

the links fo the images goes wrong, the same if a call othes action

http://www.site.com/welcome/demos

can you help me?
Colin L. (Guest)
on 2009-05-11 14:01
(Received via mailing list)
How are you linking to the images?

2009/5/11 Quijote70 <removed_email_address@domain.invalid>
Sergio A. (Guest)
on 2009-05-11 14:05
(Received via mailing list)
In html

http://www.site.com/welcome/
works

<img src="../img/head_player.jpg" width="275" height="39" />

http://www.site.com/
works
<img src="img/head_player.jpg" width="275" height="39" />
Colin L. (Guest)
on 2009-05-11 14:15
(Received via mailing list)
Try <img src="/img/head_player.jpg" width="275" height="39" />

Colin

2009/5/11 Sergio A. <removed_email_address@domain.invalid>
Sergio A. (Guest)
on 2009-05-11 14:25
(Received via mailing list)
Yes it works, but is not xhtml compliant, i am looking for a routing
solution?

Sergio
Colin L. (Guest)
on 2009-05-11 16:39
(Received via mailing list)
In what way is it not xhtml compliant?

2009/5/11 Sergio A. <removed_email_address@domain.invalid>
Sergio A. (Guest)
on 2009-05-11 18:39
(Received via mailing list)
Yes you are right, I make a mistake reading.
Sergio
Py J. (Guest)
on 2009-05-12 00:52
a good way to avoid such path issues is to use the image_tag
helper method:

image_tag("icon")  # => <img src="/images/icon" alt="Icon" />
This topic is locked and can not be replied to.