link to - Rails, link_to helper with an URL as a param -
i want generate next html link:
<a href="http://url.com">http://url.com</a>
to reproduce using link_to
helper have write:
<%= link_to "http://url.com", "http://url.com" %>
what doesn't dry @ all, expecting work:
<%= link_to "http://url.com" %>
but above code generate link targeting actual request.url
, not 1 i'm sending in param.
am missing something?
you're not missing --- normal case url , text shows user different.
if you'd like, create helper like
def link_to_href(link, args={}) link_to link, link, args end
then, when use it,
<%= link_to_href "http://url.com" %>
will output
<a href="http://url.com">http://url.com</a>
Comments
Post a Comment