Kaminari in Cells

Nick Sutterer edited this page May 13, 2014 · 4 revisions

Use Kaminari-Cells

A very convenient way is to use the kaminari-cells gem. It is not more than 10 lines of code and simply works.

Do It Yourself

Kaminari looks its partials in Rails view_paths, so to use it from Cells, you should do few additional steps:

  1. Run rails g kaminari:views default to generate copy of kaminari views inside your app
  2. Generate an initializer for kaminari with rails g kaminari:config:
  3. Edit this file and add this code at the beginning:
Kaminari::Helpers::Tag.class_eval do
  def to_s(locals = {}) #:nodoc:
    @template.render :partial => "../views/kaminari/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals)

After that, Kaminari calls from Cell will render app/cells/../views/kaminari/* files, so you don't need to add the entire app/views folder to Cells view paths