Open rossinkiwi opened 4 years ago
I think I figured this out. Rails magic is creating a polymorphic association behind the scenes. So, if in your model you declare
class Event < ApplicationRecord
has_rich_text :description
Then in deep cloneable
@event = orig_event.deep_clone include: [ :rich_text_description ], use_dictionary: true do |orig, clone|
...
Hi! Glad you figured it out :) Maybe a good idea to add it to the README?
In my use case the ActionText content contains only styled text and for that case the solution I provided works well.
However, the full ActionText implementation allows embedded attachments (images) as well. I believe cloning an ActionText field with embedded attachments would take more work - probably something similar to how ActiveStorage attachments are handled.
Ideally, a README entry would provide a solution for the full ActionText implementation rather than my special (no embedded attachments) case, and unfortunately I don't know how to do that yet :(
Thank you so much for your amazing Gem! Rails 6 added Action Text. How would you recommend cloning models with "has_rich_text" associations?