Skip to content

Instantly share code, notes, and snippets.

@agile
Created March 5, 2009 22:56
Show Gist options
  • Save agile/74621 to your computer and use it in GitHub Desktop.
Save agile/74621 to your computer and use it in GitHub Desktop.
310 # This all happens inside a transaction, _if_ the Transactions module is included into
311 # ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
312 def save_has_one_association(reflection)
313 if association = association_instance_get(reflection.name)
314 debugger unless association.respond_to?(:new_record?)
=> 315 if reflection.options[:autosave] && association.marked_for_destruction?
316 association.destroy
317 elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave]
318 association[reflection.primary_key_name] = id
319 association.save(false)
/home/mike/biggu/whiteform.git/vendor/rails/activerecord/lib/active_record/autosave_association.rb:315
if reflection.options[:autosave] && association.marked_for_destruction?
(rdb:1) association
nil
(rdb:1) association.class
nil
(rdb:1) association.nil?
false
(rdb:1) y association
nil
(rdb:1) y nil
---
nil
# how do I end up inside that conditional with a nil?
# if it's really a nil, what's up with :nil? => false ?
really weird.. the association is a has_many :through, btw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment