As title, in my mailer views, I need a helper to convert pathes to URLs:
= link_to "Click Me", convert_to_urlh#with_hash")
I expected convert_to_url("/some_path#with_hash")
to generate http://localhost:3000/some_path#with_hash
.
As title, in my mailer views, I need a helper to convert pathes to URLs:
= link_to "Click Me", convert_to_urlh#with_hash")
I expected convert_to_url("/some_path#with_hash")
to generate http://localhost:3000/some_path#with_hash
.
If you want to get URL in ActionMailer, then you need to specify :host
. You can use plain url_for
, polymorphic_url
or generated named routes methods.
For example:
<%= link_to 'Click me', user_url(@user, host: "example.com") %>
In views and controllers Rails substitute :host
automagically
More information:
url_for
: http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.htmlpolymorphic_url
: http://apidock.com/rails/ActionDispatch/Routing/PolymorphicRoutes
You don't need to call
url_for
here as thelink_to
method already calls it with the second argument. Instead try this: