Routing: resource_path or resource_url?

When you 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 make any difference.

+2


source to share


1 answer


foo_url

includes 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

      



In most cases, you want "_path", but you have a choice.

+5


source







All Articles