lib/monarchy/acts_as_resource.rb in monarchy-2.3.0 vs lib/monarchy/acts_as_resource.rb in monarchy-2.4.0

- old
+ new

@@ -61,13 +61,13 @@ end) end # rubocop:enable all def include_relationships + has_one :hierarchy, as: :resource, dependent: :destroy, class_name: "::#{Monarchy.hierarchy_class}" has_many :members, through: :hierarchy, class_name: "::#{Monarchy.member_class}" has_many :users, through: :members, class_name: "::#{Monarchy.user_class}" - has_one :hierarchy, as: :resource, dependent: :destroy, class_name: "::#{Monarchy.hierarchy_class}" end end module InstanceMethods def parent @@ -109,10 +109,10 @@ def assign_parent(force = false) parentize = self.class.parentize_name return unless parentize keys = relation_keys(parentize) - was_changed = changes[keys[:foreign_key]] || changes[keys[:foreign_type]] + was_changed = saved_changes[keys[:foreign_key]] || saved_changes[keys[:foreign_type]] Monarchy::Validators.resource(send(parentize), true, false) self.parent = send(parentize) if was_changed || force end def relation_keys(relation_name)