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`.
This commit is contained in:
patbenatar 2014-05-28 15:48:58 -07:00
parent bfa54e9b19
commit f5c1a1d2ad
1 changed files with 1 additions and 1 deletions

View File

@ -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,