Can I use a link_to to generate a link with a span inside?

Alex picture Alex · Jan 29, 2011 · Viewed 13.4k times · Source

I am basically trying to get this result:

        <a href="#" class="button small-button green-button">
            Log in
            <span class="button-right"></span>
        </a>

But I don't know how to do this with a link_to in rails 3 ?

Answer

Jeremy Ruten picture Jeremy Ruten · Jan 29, 2011

You can use the block form of link_to for that:

<%= link_to "#", :class => "button small-button green-button" do %>
  Log in
  <span class="button-right"></span>
<% end %>