user2911232
user2911232

Reputation:

Complex a tag to link_to

A designer gave me the following code snippet:

      <a href="register_learner.html">
        <div class="service-block service-block-sea service-or">
          <div class="service-bg"></div>
          <i class="icon-custom icon-color-light rounded-x fa fa-user-plus"></i>
          <h2 class="heading-md">Register a Learner</h2>
        </div>
      </a>

which I am suppose to make into a single link_to. Is this possible in Rails and if so a hint would be appreciated.

Or maybe am I seeing it wrong? I tried to put the divs out and then put the link_to 'Register Learner', new learner_path in the middle of them but it was not working.

Upvotes: 2

Views: 103

Answers (1)

Max Williams
Max Williams

Reputation: 32955

in rails you could do this like

 <%= link_to "register_learner" do %>
    <div class="service-block service-block-sea service-or">
      <div class="service-bg"></div>
      <i class="icon-custom icon-color-light rounded-x fa fa-user-plus"></i>
      <h2 class="heading-md">Register a Learner</h2>
    </div>
  <% end %>

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

EDIT - as an aside, putting divs inside a tags used to be frowned upon but is now acceptable practise, as long as there are no interactive elements inside the contents. eg, don't put another link inside.

Upvotes: 3

Related Questions