moiristo / deep_cloneable

This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations.
MIT License
786 stars 88 forks source link

block not invoked when using :include option for deeply nested object #83

Closed stepheneb closed 7 years ago

stepheneb commented 7 years ago

I am trying to clone my Meeting object.

It all works except for copying the the PaperClip image attachment in one of the polymorphic Item objects.

When I added a block to process these model objects separately it seems the block is never evaluated.

I then added a debugger halt and it never got called either.


new_meeting = self.deep_clone include: { topics: { topic_items: :item } } do |original, kopy|
  byebug
  kopy.image = original.image if kopy.respond_to?(:image)
end
stepheneb commented 7 years ago

I've duplicated this scenario in the tests for deep_cloneable ... and it works in the tests!

So obviously there is a difference I haven't discovered yet.

stepheneb commented 7 years ago

Found the issue, not surprised it was my fault.