Reputation: 4270
While not documented well nor shown in examples, url_for
can be used with paths (e.g., url_for(signup_path)
would produce /signup
) vs controllers and actions.
However, in doing do it does not include the host if one set in corresponding environment file.
reference: http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html
Why is this the behavior?
Upvotes: 0
Views: 685
Reputation: 21
Using url_for to generate a link in an email is probably not the way you want to go. In any case use signup_url not signup_path if you want the proper environment appended to the link.
<%= link_to "Signup", signup_url %>
Upvotes: 0
Reputation: 6682
If you want the full URL, use:
url_for(signup_url)
From the Rails Guide on route helpers:
Each of these [
_path
] helpers has a corresponding_url
helper (such asphotos_url
) which returns the same path prefixed with the current host, port and path prefix.
Upvotes: 2