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.
B1cb30b86898d7f51fb1b56b1de332c1?d=identicon&s=25 Spyros Vasileiadis (kleas)
on 2006-12-31 20: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
3bef3fc4d0cbcf58f3d66c106e2fd16f?d=identicon&s=25 Mark Van Holstyn (Guest)
on 2006-12-31 20: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, spyridon.vasileiadis@googlemail.com <
spyridon.vasileiadis@googlemail.com> 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 Holstyn
mvanholstyn@gmail.com
http://lotswholetime.com
B1cb30b86898d7f51fb1b56b1de332c1?d=identicon&s=25 Spyros Vasileiadis (kleas)
on 2006-12-31 21: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?
C693bf945a77e556113eee5003726343?d=identicon&s=25 tjstankus@gmail.com (Guest)
on 2007-01-02 03: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.