Sha256: 732fab02616158fcdded0c441569244308510b6440ce4be908780901fe6e3cfc
Contents?: true
Size: 740 Bytes
Versions: 53
Compression:
Stored size: 740 Bytes
Contents
module ActiveRecord::Associations::Builder # :nodoc: class HasOne < SingularAssociation #:nodoc: def self.macro :has_one end def self.valid_options(options) valid = super + [:as] valid += [:through, :source, :source_type] if options[:through] valid end def self.valid_dependent_options [:destroy, :delete, :nullify, :restrict_with_error, :restrict_with_exception] end def self.add_destroy_callbacks(model, reflection) super unless reflection.options[:through] end def self.define_validations(model, reflection) super if reflection.options[:required] model.validates_presence_of reflection.name, message: :required end end end end
Version data entries
53 entries across 53 versions & 4 rubygems