Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1904 from vyorkin/feature/paper_trail_custom_vers…

…ion_classes

Support for paper_trail custom version classes
  • Loading branch information...
commit 952b37b43087a355e40d816e3d11a72716bd05aa 2 parents 14f6c75 + 959e1bd
Mitsuhiro Shibuya mshibuya authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
13 lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
View
@@ -87,13 +87,24 @@ def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, p
sort = :created_at
sort_reverse = 'true'
end
- versions = @version_class.where item_type: model.model.name
+
+ model_name = model.model.name
+
+ versions = version_class_for(model_name).where item_type: model_name
versions = versions.where item_id: object.id if object
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)
versions.collect { |version| VersionProxy.new(version, @user_class) }
end
+
+ def version_class_for(model_name)
+ klass = model_name.constantize
+ .try(:version_class_name)
+ .try(:constantize)
+
+ klass || @version_class
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.