link_to with additional html within anchor tag

14,196

You Could do:

 <%= link_to 'index.html', :title => "Some link" do %>
     <h3> Stephen Weber </h3>
     ...
 <% end %>
Share:
14,196

Related videos on Youtube

Jeff B
Author by

Jeff B

Just another geek with an idea, Mac Book Pro, and a Nikon D200.

Updated on April 09, 2020

Comments

  • Jeff B
    Jeff B about 4 years

    How do I add additional content to a link when using the link_to helper in Rails?

    link_to "Stephen Weber", "index.html"
    

    creates this:

    <a href="index.html">Stephen Weber</a>
    

    But what if I want to create this?

    <a href="index.html">
        <h3>Stephen Weber</h3>
        <p><strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p>
        <p>Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the jQuery team.</p>
        <p class="ui-li-aside"><strong>6:24</strong>PM</p>
    </a>
    

    I'm playing around with jQuery Mobile and this is what is required for formatting content in lists.

  • Jeff B
    Jeff B about 13 years
    Thank you. I feel so stupid. I forgot you could pass in a block. I'll eventually learn this stuff especially with the awesome support of the community!
  • theschmitzer
    theschmitzer over 12 years
    I had to change "<%= link_to" to "<% link to" to avoid compilation error, FYI.