Class: ActiveRecord::Associations::Association
- Inherits:
-
Object
- Object
- ActiveRecord::Associations::Association
- Defined in:
- lib/composite_primary_keys/associations/association.rb
Instance Method Summary collapse
Instance Method Details
#creation_attributes ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/composite_primary_keys/associations/association.rb', line 4 def creation_attributes attributes = {} if (reflection.has_one? || reflection.collection?) && ![:through] # CPK # attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key] Array(reflection.foreign_key).zip(Array(reflection.active_record_primary_key)).each do |key1, key2| attributes[key1] = owner[key2] end if reflection.type attributes[reflection.type] = owner.class.polymorphic_name end end attributes end |