firstruby

Master ruby with us

Archive for July, 2010

link_to with HTML tags with linking text in Rails 3.x

Posted by firstruby on July 25, 2010

If there is HTML tag within tag like,

<a href=”#”><span>Click Me</span></a>

then to write the similar in rails >= 3.x is as follows,

In Rails >= 3.x,

<%= link_to raw("<span>Click Me</span>"), users_path %>

and in rails < 3.x,

<%= link_to "<span>Click Me</span>", users_path %>

Posted in Useful Links | Tagged: , | 1 Comment »