Class: ActiveRecord::Associations::HasOneAssociation
- Inherits:
-
Object
- Object
- ActiveRecord::Associations::HasOneAssociation
- Defined in:
- lib/classy-inheritance.rb
Instance Method Summary collapse
-
#set_belongs_to_association_for(record) ⇒ Object
this is fixed in 2.3, but it doesn’t hurt to leave it here.
Instance Method Details
#set_belongs_to_association_for(record) ⇒ Object
this is fixed in 2.3, but it doesn’t hurt to leave it here
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/classy-inheritance.rb', line 44 def set_belongs_to_association_for(record) if @reflection.[:as] record["#{@reflection.[:as]}_id"] = @owner.id unless @owner.new_record? record["#{@reflection.[:as]}_type"] = @owner.class.base_class.name.to_s else unless @owner.new_record? primary_key = @reflection.[:primary_key] || :id record[@reflection.primary_key_name] = @owner.send(primary_key) end end end |