html - weird formatting result in rails app -
i have following partial display stuff. however, page renders 1 element on first row, 3 on next, etc. last row has 2 elements. essentially, there shift. reason happening?
<% @albums.each_with_index |album, i| %> <%if i==0 || i==3 || i==6 || i==9 %> <div class="row"> <div class="col-lg-4"> <% if album["image"][2]["#text"] != nil %> <img class="img-circle" src="<%= album["image"][2]["#text"] %>" width="140" height="140"> <% else %> <img class="img-circle" src="<%= image_path("rec.png") %>" width="140" height="140"> <% end %> <h2><%= album["name"] %></h2> <p> <strong>by: </strong><%= album["artist"] %><br> <div> <%= form_tag(:action => "add_album") %> <%= hidden_field_tag 'album_name', album["name"] %> <%= hidden_field_tag 'album_artist', album["artist"] %> <%= hidden_field_tag 'album_id', album["id"] %> <%= hidden_field_tag 'album_image', album["image"][2]["#text"]%> <%= hidden_field_tag 'album_image_large', album["image"][3]["#text"] %> <%= submit_tag("add") %> <% end %> </div> </p> </div> </div> <%else%> <div class="col-lg-4"> <% if album["image"][2]["#text"] != nil %> <img class="img-circle" src="<%= album["image"][2]["#text"] %>" width="140" height="140"> <% else %> <img class="img-circle" src="<%= image_path("rec.png") %>" width="140" height="140"> <% end %> <h2><%= album["name"] %></h2> <p> <strong>by: </strong><%= album["artist"] %><br> <div> <%= form_tag(:action => "add_album") %> <%= hidden_field_tag 'album_name', album["name"] %> <%= hidden_field_tag 'album_artist', album["artist"] %> <%= hidden_field_tag 'album_id', album["id"] %> <%= hidden_field_tag 'album_image', album["image"][2]["#text"]%> <%= hidden_field_tag 'album_image_large', album["image"][3]["#text"] %> <%= submit_tag("add") %> <% end %> </div> </p> </div> <%end%> <% end %>
Comments
Post a Comment