ruby on rails - Definition of a named route in RoR? -
i see plenty of examples of named routes on web, i'm having trouble finding , why called named routes. halp.
named routes provide helper methods generating paths specific route. when define named route, 2 helper methods: name_path
, name_url
.
the difference between 2 name_url
full url protocol, domain name , port.
example:
name_path -> /test name_url -> http://localhost:3000:/test
so can see benefit when need reference these paths can use names instead of spelling out full route path.
in following example 1 rather type?
<%= link_to "test", name_url %>
or
<%= link_to "test", "http://localhost:3000/test" %>
Comments
Post a Comment