Arun Yadav
Arun Yadav

Reputation: 51

missing pagination in rails_admin view

Need some idea on this issue.

I do not see pagination link on any of the rails_admin index page for models.

There is no error in the log or firebug console.

I have gone through rails_admin wiki.

I do not see any configuration option which affect pagination, except one below

http://github.com/sferik/rails_admin/wiki/List

If in config/initializer/rails_admin.rb I set:

config.default_items_per_page = 5

It just show 5 records, changing it change the number of item displayed on the page, but pagination link do not appear.

The strange thing I noticed, that changing item_per_page, also change the total count. I mean, if at bottom of the page it show total record 20(there is 20 record in database), without the above option set.

setting it to 5 as above, also change total count to 5.

I am using, current version of rails_admin 0.4.9

Upvotes: 0

Views: 1533

Answers (1)

Arun Yadav
Arun Yadav

Reputation: 51

Finally, I figured out the solution myself and its working now. I have documented the solution with detail explanation in this blog.

In short, just create a file with name will_paginate_patch.rb in config/initializer folder of your app, and add below lines to it.

if defined?(WillPaginate)
   module WillPaginate
     module ActiveRecord
       module RelationMethods
         def per(value = nil)
           per_page(value)
         end
         def total_count()
           count
         end
       end
     end
   module CollectionMethods
     alias_method :num_pages, :total_pages
   end
  end
end

Upvotes: 3

Related Questions