Articles tagged 'will_paginate'

  • Rails 3.1 - will_paginate and AJAX

    November 10, 2011


    This post was originally published in the Rambling Labs Blog on November 10, 2011.


    For a project that I’m currently working on, I have a couple of list views that needed pagination. So I went with the ol’ will_paginate gem (which I first saw years ago when I didn’t even consider myself a developer) to take care of this.

    It’s as simple as including a line with gem 'will_paginate' on your Gemfile, running bundle install, and include this in the controller:

    class OrdersController < ApplicationController
      def index
        @orders = Order.paginate(page: params[:page], per_page: 10)
      end
    end
    

    And this in the view orders/index.html.erb:

    <div id="orders">
      <ul>
        <% @orders.each do |order| %>
          <li>
              <!-- Show order stuff --...

    Continue Reading →