51224bdd17878b3b19e8987e9bb336a2

In following code ul getting repeat after showing 3 feed items in the li.

<ul>			  
    
  <% if @feeds[16..19] %>
    <% @feeds[16..19].each do |feed| -%>

   <li style="width:170px">
     <input name="source[<%=feed.id %>]" type="checkbox" value="<%=feed.id %>" "checked" />
     <%=feed.name %> 
   </li>
 
    <% end -%>
  <% end -%>
 
</ul>


<ul>			  
    
  <% if @feeds[20..23] %>
    <% @feeds[20..23].each do |feed| -%>

   <li style="width:170px">
    <input name="source[<%=feed.id %>]" type="checkbox" value="<%=feed.id %>" "checked" />
    <%=feed.name %> 
   </li>
 
    <% end -%>
  <% end -%>
 
</ul>

Refactorings

No refactoring yet !

A8d3f35baafdaea851914b17dae9e1fc

Adam

November 7, 2008, November 07, 2008 00:52, permalink

2 ratings. Login to rate!
<% @feeds.each_slice(3) do |feeds| %>
  <ul>
    <% feeds.each do |feed| %>
      <% content_tag_for(:li, feed) do %>
        <%= check_box_tag "source[#{feed.id}]", feed.id, true %>
        <%=h feed.name %>
      <% end %>
    <% end %>
  </ul>
<% end %>

Your refactoring





Format Copy from initial code

or Cancel