firstruby

Master ruby with us

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 %>

Advertisements

One Response to “link_to with HTML tags with linking text in Rails 3.x”

  1. Itís awesome to pay a quick visit this web page and reading the views of all friends about this post, while I am also eager of getting experience.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: