On Mar 1, 5:21 am, "tashfeen.ekram" <[email protected]> wrote:
> i am using link_to to make links. it is gnerating urls relative to the
> path of the page. how do i make absolute urls. i tried using only_path
> but it does nto seem to work.

A few ways that work for me are:

link_to 'Home', '/home'   # => <a href='/home'>Home</a>
link_to 'Home', 'http://www.mysite.com/home'  # => <a href='http://
www.mysite.com/home'>Home</a>
link_to 'Home', :controller => '/home' # note the '/' in front of
home  <a href='/home'>Home</a>

> do i need to use url_for?

link_to already uses url_for if I understand well.

only_path is used to make URL's relative to the root (first '/') of
this URL.
Is useful when behind a proxy (e.g. an SSL proxy).

Much more info can be found on http://api.rubyonrails.org searching
the method:

  url_for (ActionController::Base)

HTH,

Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to