How to get root path with link_to?

Hi,

I would like to get the root path of my website using link_to in a
view… (for example : http://www.mywebsite/controller/action/id)
how is that possible ?

(i do need it, because i use the generated code in the view outside of
the rails app’)

Thanks…

guillaume wrote:

Hi,

I would like to get the root path of my website using link_to in a
view… (for example : http://www.mywebsite/controller/action/id)
how is that possible ?

(i do need it, because i use the generated code in the view outside of
the rails app’)

Thanks…

in routes.rb:
map.root ‘/’

in your view:
link_to ‘link to root’, root_url

Is that what you need?

-Sjoerd

Patrick Sullivan wrote:

Or you could just do this:

link_to “Link”, “/”

True, however won’t that just generate a relative url? So Link instead of Link?
I believe Guillaume requires the latter, as his views are also used
outside of his app.

Or you could just do this:

link_to “Link”, “/”

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