Issue
I am new to programming, just completed RailsTutorial and now am trying to build a Pinterest-type site using Rails.
I'd like for the main site to display items through multiple columns and in an infinite loop like:
1 2 3 4 5
6 7 8 9 10
. . . . .
I've got the layout that I'd like, but don't know how to break the content feed into the multiple divs.
home.html.erb (I know this is wrong)
<% if signed_in? %>
<div id="container" summary="For signed-in users">
<div class="news-column1"><%= render 'shared/feed' %></div>
<div class="news-column2"><%= render 'shared/feed' %></div>
<div class="news-column3"><%= render 'shared/feed' %></div>
<div class="news-column4"><%= render 'shared/feed' %></div>
<div class="news-column5"><%= render 'shared/feed' %></div>
<% else %>
...
<% end %>
_feed.html.erb
<% if @feed_items.any? %>
<%= render :partial => 'shared/feed_item', :collection => @feed_items %>
<% end %>
_feed_item.html.erb
<div class="news">
<div class="comments">
<%= wrap(feed_item.content) %>
</div>
<div class="stats">
#Likes, #Comments, #Repins
</div>
<div class="points">
<%= link_to feed_item.user.name, feed_item.user %>
</div>
<div class="author">
Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
</div>
</div>
<% if current_user?(feed_item.user) %>
<div>
<%= link_to "delete", feed_item, :method => :delete,
:confirm => "You sure?",
:title => feed_item.content %>
</div>
<% end %>
Solution
Ryan Bates has shown you how to do this here:
as a summary here is the code:
<table>
<% @tasks.in_groups_of(5, false) do |row_tasks| %>
<tr>
<% for task in row_tasks %>
<td><%= task.name %></td>
<% end %>
</tr>
<% end %>
</table>
Answered By - nodrog Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.