Module: ActiveRecordLaxIncludes::Base
- Defined in:
- lib/activerecord_lax_includes.rb
Instance Method Summary collapse
Instance Method Details
#association(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/activerecord_lax_includes.rb', line 19 def association(name) association = association_instance_get(name) if association.nil? if reflection = self.class._reflect_on_association(name) association = reflection.association_class.new(self, reflection) association_instance_set(name, association) elsif !ActiveRecord.lax_includes_enabled? raise ActiveRecord::AssociationNotFoundError.new(self, name) end end association end |