Class: ActiveRecord::Associations::Builder::BelongsTo

Inherits:
SingularAssociation show all
Defined in:
activerecord/lib/active_record/associations/builder/belongs_to.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Association

#model, #name, #options, #reflection

Instance Method Summary collapse

Methods inherited from SingularAssociation

#define_accessors

Methods inherited from Association

build, #initialize, #mixin

Constructor Details

This class inherits a constructor from ActiveRecord::Associations::Builder::Association

Instance Method Details

#buildObject



13
14
15
16
17
18
19
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 13

def build
  reflection = super
  add_counter_cache_callbacks(reflection) if options[:counter_cache]
  add_touch_callbacks(reflection)         if options[:touch]
  configure_dependency
  reflection
end

#constructable?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 9

def constructable?
  !options[:polymorphic]
end