Module: ActiveRecord::Associations::ClassMethods

Defined in:
lib/active_record/associations/embeds_one_association.rb,
lib/active_record/associations/embeds_one_association.rb

Instance Method Summary collapse

Instance Method Details

#embeds(name, options = {}) ⇒ Object

Parameters:

  • name (Symbol, String)

    of association

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :validate (Boolean)

    Validate associaited object (default: true)

  • :class_name (String)

    Name of the associated class



12
13
14
15
16
# File 'lib/active_record/associations/embeds_one_association.rb', line 12

def embeds(name, scope = nil, options = {}, &extension)
  validates_associated(name) unless options.delete(:validate) == false
  reflection = Builder::EmbedsOne.build(self, name, options, nil)
  Reflection.add_reflection self, name, reflection
end