Permalink
Browse files

Fixed history query for model subclasses

  • Loading branch information...
Tuckie committed Mar 15, 2013
1 parent 51f2c8b commit b9c8a97544d31381abf891071dfd560f4d852875
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
@@ -67,7 +67,11 @@ def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (R
sort = :created_at
sort_reverse = "true"
end
- versions = ::Version.where :item_type => model.model.name
+ if model.model.base_class.name == model.model.name
+ versions = ::Version.where :item_type => model.model.name
+ else
+ versions = ::Version.where :item_id => model.model.all
+ end
versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
versions = all ? versions : versions.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
@@ -81,7 +85,7 @@ def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_
sort = :created_at
sort_reverse = "true"
end
- versions = ::Version.where :item_type => model.model.name, :item_id => object.id
+ versions = ::Version.where :item_type => model.model.base_class.name, :item_id => object.id
versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
versions = all ? versions : versions.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)

0 comments on commit b9c8a97

Please sign in to comment.