Module: ActiveRecord::Associations::ClassMethods

Defined in:
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



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

def embeds(name, options = {})
  validates_associated(name) unless options.delete(:validate) == false
  if ActiveRecord::VERSION::MAJOR < 4
    Builder::EmbedsOne.build(self, name, options)
  else
    Builder::EmbedsOne.build(self, name, options, nil)
  end
end