0

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

4

1 回答 1

3

最后,我自己想出了解决方案并且它现在可以工作了。我已在博客中记录了解决方案并提供了详细说明。

简而言之,只需在应用程序的 config/initializer 文件夹中创建一个名为 will_paginate_patch.rb 的文件,然后在其中添加以下行。

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
于 2013-06-19T09:11:52.513 回答