def validate(*args)
      # First clear all previous errors
      clear_errors

      # Then do the validations
      failed = false
      self.class.relationships.each do |name, options|
        next unless options && options[:klass].respond_to?(:validate_relationship)
        failed = true if !options[:klass].validate_relationship(self, relationship_data[name], *args)
      end

      return !failed
    end
def validate(*args)
      # First clear all previous errors
      clear_errors

      # Then do the validations
      failed = false
      self.class.relationships.each do |name, options|
        next unless options && options[:klass].respond_to?(:validate_relationship)
        failed = true if !options[:klass].validate_relationship(self, relationship_data[name], *args)
      end

      return !failed
    end
Validates the model and relationships.