From 83d781ed01459cb80d10a1c8e91e3d6f36c01913 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 7 Jun 2018 14:38:57 +0200 Subject: Add scope to preload embeds as well --- lib/action_text/attribute.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/action_text/attribute.rb') diff --git a/lib/action_text/attribute.rb b/lib/action_text/attribute.rb index 30cbab70db..6ed72fd852 100644 --- a/lib/action_text/attribute.rb +++ b/lib/action_text/attribute.rb @@ -17,6 +17,7 @@ module ActionText has_one :"rich_text_#{name}", -> { where(name: name) }, class_name: "ActionText::RichText", as: :record, inverse_of: :record, 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 { public_send(name).save if public_send(name).changed? } end -- cgit v1.2.3