Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more accurate page_entries_info for pagination

  • Loading branch information...
commit 56a4c230eb1a426399d9e3b5ffa9a141f781b445 1 parent 96a0cfa
@damrbaby damrbaby authored
View
6 lib/active_admin/comments/comment.rb
@@ -1,5 +1,10 @@
+require 'kaminari/models/active_record_extension'
+
module ActiveAdmin
+ # manually initialize kaminari for this model
+ ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
+
class Comment < ActiveRecord::Base
self.table_name = "active_admin_comments"
@@ -13,3 +18,4 @@ class Comment < ActiveRecord::Base
end
end
+
View
4 lib/active_admin/views/components/paginated_collection.rb
@@ -81,10 +81,10 @@ def page_entries_info(options = {})
else; "Displaying <b>all #{collection.size}</b> #{entry_name.pluralize}"
end
else
- offset = collection.current_page * collection.per_page
+ offset = collection.current_page * ActiveAdmin.default_per_page
total = collection.total_count
%{Displaying #{entry_name.pluralize} <b>%d&nbsp;-&nbsp;%d</b> of <b>%d</b> in total} % [
- offset - collection.per_page + 1,
+ offset - ActiveAdmin.default_per_page + 1,
offset > total ? total : offset,
total
]
Please sign in to comment.
Something went wrong with that request. Please try again.