loops - Process return of select from database in erb view in ruby on rails -
i'm trying process array/list came database. here's how it:
@amenities = amenitiesandfeatures.select("name").where(is_amenities: true).order("name asc") div class="e-float-left"> <%(@amenities.each) |amenities|%> <p><input type="checkbox" class="listing-check"> <%=amenities.name%></p> <%end%> </div></td>
i can display data sequentially using code. want add logic it.
what want accomplish create loop loop in .net. how can construct in ror this?
var x = amenities.length for(int = 0; <= x/2;i++) { <p><input type="checkbox" class="listing-check"> amenities.name[i]</p> }
i doing on erb view. i'm trying pull name column on amenitiesandfeatures , process each 1 inside loop.
please try this
x=@amenities.size/2
<% @amenities.each_with_index |amenity,i|%>
<% if <= x %>
<p><input type="checkbox" class="listing-check">
<%= @amenities[i].name %></p>
<% end %>
<%end%>
Comments
Post a Comment