lib/pg_serializable/visitors/validation.rb in pg_serializable-1.3.0 vs lib/pg_serializable/visitors/validation.rb in pg_serializable-1.3.1
- old
+ new
@@ -54,9 +54,10 @@
def check_for_cycles(subject)
case subject
when trait? then subject.attribute_nodes.each { |node| check_for_cycles(node) }
when association?
+ return if subject.association.nil? # skip if association isn't loaded yet, it'll get caught later
if subject.target == @root_klass
raise PgSerializable::AssociationError.new("class #{@root_klass} contains a cycle in nested association #{subject.klass}")
end
associated_trait = subject.target.trait_manager.get_trait subject.trait
check_for_cycles(associated_trait)