0

How can I take this..

  <li>
  <%= link_to image_tag(product.photo.url(:small)), product_path(product.id, :forum_id => params[:forum_id]) %> 
<% if params[:forum_id] %>
  <%= link_to "Add", addtoforum_user_path(:products => [product.id],:forum_id => params[:forum_id], tp: "add") %>
  </li>

to be like this.. (right now it is only inlcluding the image)

<li>
   <a href="">
       <figure>
       <img src="image-url....">
       </figure>
       <span>product name</span>
   </a>
</li>

Thanks

1 Answer 1

1

Not sure I understand the question but I guess the issue is to output the figure, img tags etc inside the a tag?

This can be achieved by passing a block to the link_to method, like this:

<li>
  <%= link_to product_path(product.id, :forum_id => params[:forum_id]) do %>
   <figure>
   <%= image_tag(product.photo.url(:small)) %>
   </figure>
   <span><%= product.name %></span>
  <% end %>
</li>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.