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

Issue duplicating associations with attachments with pg_search installed #30

Closed rmatesic closed 10 years ago

rmatesic commented 11 years ago

I have my model Customer which has many customer documents. Inside a document I am using carrierwave to save an attachment.

From looking at previous posts on how to properly copy carrierwave attachments I was able to get my documents and their attachments cloned from the code below.

new_cusotmer = self.dup include: [{ customer_documents: :document }], validate: false do |original, kopy|]
  # Clone Attachments
  kopy.attachment = original.attachment if kopy.is_a?(Document)
end
new_customer.save!

The problem I am getting is that when I included the gem pg_search under my customer model, it still clones the customer and all its documents but it doesn't create an attachment anymore. It copies the original.attachment to the kopy.attachment but if I was to run

document.attachment?

it returns false because no file was created.

I am only having this issue when I am including pg_search in my customer model and was just wondering why this could be happening and if anyone else has experianced this.

moiristo commented 11 years ago

Didn't know about that gem, thanks :) It does seem that the pg_search gem conflicts with carrierwave somehow. I'm not convinced that deep_cloneable is part of the problem here.

rmatesic commented 11 years ago

Yes I wasn't sure which gem was causing it. Spent too much time today trying to work out why its happening. On 20/09/2013 5:57 PM, "Reinier de Lange" notifications@github.com wrote:

Didn't know about that gem, thanks :) It does seem that the pg_search gem conflicts with carrierwave somehow. I'm not convinced that deep_cloneable is part of the problem here.

— Reply to this email directly or view it on GitHubhttps://github.com/moiristo/deep_cloneable/issues/30#issuecomment-24795151 .