Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (24 sloc) 0.745 kB
module ActiveRecord::Associations::Builder
class HasOne < SingularAssociation #:nodoc:
def self.macro
:has_one
end
def self.valid_options(options)
valid = super + [:as, :foreign_type]
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
Jump to Line
Something went wrong with that request. Please try again.