Module: ActiveRecord::AutosaveAssociation
- Defined in:
- lib/classy-inheritance.rb
Instance Method Summary collapse
-
#save_has_one_association(reflection) ⇒ Object
fix active record has_one primary key bug rails 2.3 - http://rails.lighthouseapp.com/projects/8994/tickets/1756-has_one-with-foreign_key-primary_key-bug.
Instance Method Details
#save_has_one_association(reflection) ⇒ Object
fix active record has_one primary key bug rails 2.3 - http://rails.lighthouseapp.com/projects/8994/tickets/1756-has_one-with-foreign_key-primary_key-bug
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/classy-inheritance.rb', line 50 def save_has_one_association(reflection) if (association = association_instance_get(reflection.name)) && !association.target.nil? primary_key = reflection.[:primary_key] || :id if reflection.[:autosave] && association.marked_for_destruction? association.destroy elsif new_record? || association.new_record? || association[reflection.primary_key_name] != send(primary_key) || reflection.[:autosave] association[reflection.primary_key_name] = send(primary_key) association.save(false) end end end |