manshu manshu - 5 months ago 16
Ruby Question

Error wrapping link_to, image_tag and div_tag to produce this code

I have a simple HTML code, that needs to be converted in Ruby.

<div class="col-md-4 col-sm-6">
<div class="single-work">
<a class="work-thumb mb-35 light-box" href="works/img-05.jpg">
<%= image_tag 'works/img-05.jpg' %>
<div class="work-hover"></div>
</a>
<div class="work-excerp">
<a href="single-services.html"><h2>Plugin Development</h2></a>
<p>Duis autem vel eum iriure dolor in hendrerit in vulpu tate velit esse molestie consequat.</p>
</div>
</div>
</div>


Here is my Ruby Code.

<div class="col-md-4 col-sm-6">
<div class="single-work">
---> <%= link_to((image_tag'works/img-05.jpg'), image_path('works/img-05.jpg'), 'class' => 'work-thumb mb-35 light-box') %>
<div class="work-hover"></div>
<div class="work-excerp">
<a href="single-services.html"><h2>3D Design</h2></a>
<p>Duis autem vel eum iriure dolor in hendrerit in vulpu tate velit esse molestie consequat.</p>
</div>
</div>
</div>


I need this
<div class="work-hover"></div>
inside that tag ( Look for this --> arrow)

Answer

You may do something like:

<div class="col-md-4 col-sm-6">
    <div class="single-work">
        <%= link_to( image_path('works/img-05.jpg'), class: 'work-thumb mb-35 light-box') do %>
          <%= image_tag 'works/ing-05.jpg' %>
          <div class="work-hover"></div>
        <% end %>
        <div class="work-excerp">
            <a href="single-services.html"><h2>3D Design</h2></a>
            <p>Duis autem vel eum iriure dolor in hendrerit in vulpu tate velit esse molestie consequat.</p>
        </div>
    </div>
</div>
Comments