2015-07-11 64 views
0

如何把image_tag和link_to數據清除? 我試過,但它不工作如何把image_tag和link_to數據清除?

<ul class="clearing-thumbs small-block-grid-4" data-clearing> 
      <% @galleries.each do |f| %> 


      <!-- <a href= f.image.url class="gal"> --> 

       <%= link_to link_to f.image.url , image_tag(f.image.url(:medium)) %></li> 


      <div class="box_bot"> 
       <% if current_user && current_user.admin? %> 
        <%= link_to "Delete", f,class: "btn", method: :delete, data: { confirm: "Are you sure you want to delete this?" } %> 
       <% end %> 
        <!-- <a href="#" class="fa fa-chevron-right"></a> --> 

     </div> 

     <% end %> </ul> 

回答

0
<ul class="clearing-thumbs clearing-feature" data-clearing> 
      <% @galleries.each do |f| %> 


     <li>  <%= image_tag (f.image.url)%> 
<% image_tag (f.image.url(:medium)) %></li> 

感謝我解決它

0

有重複link_to link_to。你可能只需要一個。

除此之外,我建議使用parenthesise並修復可讀性縮進:

<ul class="clearing-thumbs small-block-grid-4" data-clearing> 
    <% @galleries.each do |f| %> 

    <%= link_to(f.image.url, class: 'gal') do %>  
     <%= image_tag(f.image.url(:medium)) %> 
    <% end %> 

    <div class="box_bot"> 
     <% if current_user && current_user.admin? %> 
     <%= link_to('Delete', f, 
        class: 'btn', 
        method: :delete, 
        data: { 
         confirm: 'Are you sure you want to delete this?' 
        }) %> 
     <% end %> 
    </div> 
    <% end %> 
</ul> 

而且你的例子包括關閉</li>,但沒有開放<li>。我刪除了關閉標記</li>,因爲只是結束標記是無效的HTML。您必須在適當的地方將上述代碼添加(打開和關閉標籤)。