我有以下过滤后:
用户模型:
def check_for_custom_district
unless self.custom_district.blank?
district = District.new(:name => custom_district, :state_id => state_id, :school_type_id => school_type_id)
if district.save(false)
school = School.new(:name => custom_school, :state_id => state_id, :country_id => 1, :source => "User")
if school.save(false)
district.schools << school
update_attribute(:school_id, school.id)
end
end
end
end
def check_for_custom_school
if self.custom_district.blank? and self.custom_school.present?
school = School.new(:name => custom_school, :state_id => state_id, :country_id => 1, :source => "User", :school_district_id => district_id)
school.save(false)
update_attribute(:school_id, school.id)
end
end
我进行了一些调试以将结果输出到控制台,并且代码正在访问该check_for_custom_district
方法并由于某种原因导致无限循环。不知道如何阻止这种情况......有什么想法吗?