aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_text/attribute.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-06-07 14:38:57 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-06-07 14:38:57 +0200
commit83d781ed01459cb80d10a1c8e91e3d6f36c01913 (patch)
treebb186321ef84d5a8f06b411e78e0d737ffce6c64 /lib/action_text/attribute.rb
parentd5623dc634dc6e8ce8294485e1fdb6adb5f16271 (diff)
downloadrails-83d781ed01459cb80d10a1c8e91e3d6f36c01913.tar.gz
rails-83d781ed01459cb80d10a1c8e91e3d6f36c01913.tar.bz2
rails-83d781ed01459cb80d10a1c8e91e3d6f36c01913.zip
Add scope to preload embeds as well
Diffstat (limited to 'lib/action_text/attribute.rb')
-rw-r--r--lib/action_text/attribute.rb1
1 files changed, 1 insertions, 0 deletions
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