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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -