summaryrefslogtreecommitdiff
path: root/app/models/asset.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/asset.rb')
-rw-r--r--app/models/asset.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/asset.rb b/app/models/asset.rb
index ba9c2f0..73970e2 100644
--- a/app/models/asset.rb
+++ b/app/models/asset.rb
@@ -31,4 +31,13 @@ class Asset < ApplicationRecord
31 def show_credit? 31 def show_credit?
32 image? && has_credit? 32 image? && has_credit?
33 end 33 end
34
35 # Nodes whose current lifecycle rows (head, draft or autosave) carry
36 # this asset. Historical revisions also hold RelatedAsset rows; they
37 # are excluded by construction here, since nothing points at them.
38 def attached_nodes
39 page_ids = related_assets.select(:page_id)
40 Node.where("head_id IN (:ids) OR draft_id IN (:ids) OR autosave_id IN (:ids)",
41 :ids => page_ids).distinct
42 end
34end 43end