Forum: Ruby on Rails Rest. _url vs _path

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.
Spyros V. (Guest)
on 2006-12-31 21:53
(Received via mailing list)
Hello people!

Can someone explain what the difference between the .*_url and .*_path
named routes generate by rest is?
http://cheat.errtheblog.com/b (actually down at the moment) mentions
the following (taken from peepcode.com, yay topfunky!)

"Each method also has a counterpart ending in _url that includes the
protocol,
  domain, and port."
which I dont quite get, I mean no matter wich ones I use (in dev mode)
produce the same links. could someone rephrase/explain that?

many thanks && happy new year!
Spyros
Mark Van H. (Guest)
on 2006-12-31 21:55
(Received via mailing list)
I believe that _url generates things like "
http://example.com/controller/action" and _path generates
"/controller/action"

Mark

On 12/31/06, removed_email_address@domain.invalid <
removed_email_address@domain.invalid> wrote:
> protocol,
>   domain, and port."
> which I dont quite get, I mean no matter wich ones I use (in dev mode)
> produce the same links. could someone rephrase/explain that?
>
> many thanks && happy new year!
> Spyros
>
>
> >
>


--
Mark Van H.
removed_email_address@domain.invalid
http://lotswholetime.com
Spyros V. (Guest)
on 2006-12-31 22:01
(Received via mailing list)
yeah but like i said, in the end (ie browser) a complete link is
displayed. so does it make a difference to use path instead of url,
since path does get its prefix (domain+port) by rails anyway? can it be
that it makes a difference while in production rather than dev mode?
(Guest)
on 2007-01-02 04:08
(Received via mailing list)
> yeah but like i said, in the end (ie browser) a complete link is
> displayed. so does it make a difference to use path instead of url,
> since path does get its prefix (domain+port) by rails anyway? can it be
> that it makes a difference while in production rather than dev mode?

I don't think production/dev mode makes any difference. But there are
cases where you'll need one and not the other. There may be other
examples, but it makes a difference when you're passing a named route
to the current_page? method. You'd want to use _path in that case; _url
won't work. (It's because of the way current_page? compares using
url_for and the request uri.)

-TJ
This topic is locked and can not be replied to.