views:

108

answers:

1

When you do map.resources on a model, it generates a bunch of routing helpers:

resource_path(@resource)
resource_url(@resource)
new_resource_url
etc.

What's the difference between using _path and _url? From what I've tried it doesn't seem to make any difference.

+3  A: 

foo_url includes the domain and protocol. foo_path only outputs the relative path.

>> foo_url(:id => 1)
http://localhost:3000/foo/1

>> foo_path(:id => 1)
/foo/1

Most of the time, you want "_path" but you have the choice.

jdl
It's really just personal preference. One exception, is if you're building an RSS feed or something that needs the full url, then you should definitely use resource_url()
Bill Turner