From f5c1a1d2adba03ce259881f307ac26be804d0d22 Mon Sep 17 00:00:00 2001 From: patbenatar Date: Wed, 28 May 2014 15:48:58 -0700 Subject: [PATCH] Fixes has_many conditions in Rails 4.1 Rails 4.1 passes the association into the scope lambda, not the class. Rather, the associated object's class is available within the context of the lambda as `model`. --- lib/paper_trail/has_paper_trail.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index b64c74f2..e18cc67f 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -61,7 +61,7 @@ module PaperTrail if ::ActiveRecord::VERSION::MAJOR >= 4 # `has_many` syntax for specifying order uses a lambda in Rails 4 has_many self.versions_association_name, - lambda { |model| order(model.version_class_name.constantize.timestamp_sort_order) }, + lambda { order(model.timestamp_sort_order) }, :class_name => self.version_class_name, :as => :item else has_many self.versions_association_name,