From c399f7d07a88d333fa05a361c66a252d9fa462bb Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Sun, 17 Mar 2019 17:22:46 -0400 Subject: Fix updating rich text via nested attributes Closes #35159. --- actiontext/lib/action_text/attribute.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'actiontext/lib') diff --git a/actiontext/lib/action_text/attribute.rb b/actiontext/lib/action_text/attribute.rb index f226dd21bd..f9a604096c 100644 --- a/actiontext/lib/action_text/attribute.rb +++ b/actiontext/lib/action_text/attribute.rb @@ -34,14 +34,11 @@ module ActionText end CODE - has_one :"rich_text_#{name}", -> { where(name: name) }, class_name: "ActionText::RichText", as: :record, inverse_of: :record, dependent: :destroy + has_one :"rich_text_#{name}", -> { where(name: name) }, + class_name: "ActionText::RichText", as: :record, inverse_of: :record, autosave: true, dependent: :destroy scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") } scope :"with_rich_text_#{name}_and_embeds", -> { includes("rich_text_#{name}": { embeds_attachments: :blob }) } - - after_save do - public_send(name).save if public_send(name).changed? - end end end end -- cgit v1.2.3