fix query

This commit is contained in:
Pete Matsyburka
2025-06-14 08:29:00 +03:00
parent 95627c5963
commit f2888a08dc
2 changed files with 11 additions and 9 deletions
+1 -6
View File
@@ -13,12 +13,7 @@ module Abilities
TemplateSharing.where({ ability:, account_id: [user.account_id, TemplateSharing::ALL_ID] }.compact)
.select(:template_id)
join_query =
Template.arel_table
.join(Arel::Nodes::TableAlias.new(templates.select(:id).arel.union(shared_ids.arel), 'union_ids'))
.on(Template.arel_table[:id].eq(Arel::Table.new(:union_ids)[:id]))
Template.joins(join_query.join_sources.first)
Template.where(Template.arel_table[:id].in(Arel::Nodes::Union.new(templates.select(:id).arel, shared_ids.arel)))
end
def entity(template, user:, ability: nil)