Monday, February 4, 2013

Making Will Paginate Ajax + Rails 3

1. Create a helper file : app / helpers / remote_link_pagination_helper.rb

module RemoteLinkPaginationHelper
  class LinkRenderer < WillPaginate::ActionView::LinkRenderer
    def link(text, target, attributes = {})
      attributes['data-remote'] = true
      super
    end
  end
end


2. In the View File where pagination links come, add this line. (@people is the array to paginate)

will_paginate @people, :renderer => 'RemoteLinkPaginationHelper::LinkRenderer'



Now the links must work with Ajax