title: Ruby on Rails Pagination
body: <p>I'm having trouble getting a set of data to paginate in ruby. I already have one example (newsfeed of posts by users you are 'following')</p>
  
  <p>_feed_item.html.erb</p>
  
  <pre><code>&lt;li id="&lt;%= feed_item.id %&gt;"&gt;
  &lt;%= link_to gravatar_for(feed_item.user), feed_item.user %&gt;
  &lt;span class="user"&gt;
  &lt;%= link_to feed_item.user.name, feed_item.user %&gt;
  &lt;/span&gt;
  &lt;span class="content"&gt;&lt;%= feed_item.content %&gt;&lt;/span&gt;  
  &lt;span class="timestamp"&gt;
  Posted &lt;%= time_ago_in_words(feed_item.created_at) %&gt; ago.
  &lt;/span&gt;
  # not part of the code - just a placeholder for a like button I'm writing
  &lt;span class="likebtn-wrapper" data-lang="en"&gt;&lt;/span&gt;
  ##########################
  &lt;% if current_user?(feed_item.user) %&gt;
  &lt;%= link_to "delete", feed_item, method: :delete,
  data: { confirm: "You sure?" },
  title: feed_item.content %&gt;
  &lt;% end %&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>_feed.html.erb</p>
  
  <pre><code>&lt;% if @feed_items.any? %&gt;
  &lt;ol class="microposts"&gt;
  &lt;%= render partial: 'shared/feed_item', collection: @feed_items %&gt;
  &lt;/ol&gt;
  &lt;%= will_paginate @feed_items %&gt;
  &lt;% else %&gt;
  </code></pre>
  
  <p>home.html.erb (to render the newsfeed)</p>
  
  <pre><code>&lt;%= render 'shared/feed' %&gt;
  </code></pre>
  
  <p>Because the default Home only renders posts by users who you are following - I created a "Global" post index that simply lists all posts saved to the database.</p>
  
  <p>global.html.erb</p>
  
  <pre><code>Global Feed |  
  &lt;%= User.count %&gt; Total Users |
  &lt;%= Micropost.count %&gt; Total Posts&lt;br /&gt;
  &lt;% Micropost.all.each do |micropost| %&gt;
  Global Post Number: &lt;%= micropost.id %&gt; &lt;br /&gt;
  &lt;%= link_to micropost.user.name, micropost.user %&gt; &lt;br /&gt;
  &lt;%= micropost.content %&gt;&lt;br /&gt;
  &lt;span class="timestamp"&gt;
  Posted &lt;%= time_ago_in_words(micropost.created_at) %&gt; ago.
  &lt;/span&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I tried using the same sort of technique used in for the newsfeed but it doesn't work. How would I go about paginating the results similar to the users newsfeed.</p>