Permalink
Browse files

Reset associations before preloading

  • Loading branch information...
1 parent 8bf889f commit d25b8c2f2c5a9256731d829c8a9abaf177c0f130 @lifo committed Sep 13, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/sidekick/target.rb
View
@@ -12,6 +12,12 @@ def find_target_with_kick
# Fucking STI
working_record_set = @owner._parent_record_set.find_all {|r| r.class.reflect_on_association(reflection_name) }
+ # Sorry new records. You don't belong.
+ working_record_set.each do |r|
+ x = r.send(:instance_variable_get, "@#{reflection_name}")
+ x.reset if x
+ end
+
@owner.class.send(:preload_associations, working_record_set, reflection_name.to_sym)
record_set = working_record_set.map do |r|

0 comments on commit d25b8c2

Please sign in to comment.