# Rest. \_url vs \_path

**URL:** <https://www.ruby-forum.com/t/rest-url-vs-path/80871>\
**Category:** Rails\
**Created:** [December 31, 2006, 8:53pm UTC](https://www.ruby-forum.com/t/rest-url-vs-path/80871 "2006-12-31T20:53:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kleas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/47e85d/32.png) [@kleas](https://www.ruby-forum.com/u/kleas)\
**Post date:** [December 31, 2006, 8:53pm UTC](https://www.ruby-forum.com/t/rest-url-vs-path/80871/1 "2006-12-31T20:53:28Z")

</div>

Hello people!

Can someone explain what the difference between the ._\_url and ._\_path  
named routes generate by rest is?  
[http://cheat.errtheblog.com/b](http://cheat.errtheblog.com/b) (actually down at the moment) mentions  
the following (taken from [peepcode.com](http://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

---

<div class="post-metadata">

**Author:** ![kleas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/47e85d/32.png) [@kleas](https://www.ruby-forum.com/u/kleas)\
**Post date:** [December 31, 2006, 9:01pm UTC](https://www.ruby-forum.com/t/rest-url-vs-path/80871/2 "2006-12-31T21:01:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kleas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/47e85d/32.png) [@kleas](https://www.ruby-forum.com/u/kleas)\
**Post date:** [December 31, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/rest-url-vs-path/80871/3 "2006-12-31T20:55:28Z")

</div>

I believe that \_url generates things like "  
[http://example.com/controller/action](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](http://lotswholetime.com)

---

<div class="post-metadata">

**Author:** ![kleas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/47e85d/32.png) [@kleas](https://www.ruby-forum.com/u/kleas)\
**Post date:** [January 2, 2007, 3:08am UTC](https://www.ruby-forum.com/t/rest-url-vs-path/80871/4 "2007-01-02T03:08:42Z")

</div>

> 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
