From b9c8a97544d31381abf891071dfd560f4d852875 Mon Sep 17 00:00:00 2001 From: Tuckie Date: Fri, 15 Mar 2013 16:35:19 -0300 Subject: [PATCH] Fixed history query for model subclasses --- .../extensions/paper_trail/auditing_adapter.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb b/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb index 5078157097..24e53dc529 100644 --- a/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +++ b/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)