Fix: queries were failing due to using the wrong alias

This commit is contained in:
Jorge Manrubia
2025-08-22 09:23:35 +02:00
parent c8569ce8b9
commit 2eaf462efd
2 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ module Card::Engageable
has_one :engagement, dependent: :destroy, class_name: "Card::Engagement"
scope :considering, -> { published_or_drafted_by(Current.user).open.where.missing(:engagement) }
scope :on_deck, -> { published.open.joins(:engagement).where(card_engagements: { status: "on_deck" }) }
scope :doing, -> { published.open.joins(:engagement).where(card_engagements: { status: "doing" }) }
scope :on_deck, -> { published.open.joins(:engagement).where(engagement: { status: "on_deck" }) }
scope :doing, -> { published.open.joins(:engagement).where(engagement: { status: "doing" }) }
scope :by_engagement_status, ->(status) do
case status.to_s
+3 -1
View File
@@ -18,7 +18,9 @@ class Filter < ApplicationRecord
def cards
@cards ||= begin
result = creator.accessible_cards.indexed_by(indexed_by).sorted_by(sorted_by)
result = creator.accessible_cards
result = result.indexed_by(indexed_by)
result = result.sorted_by(sorted_by)
result = result.where(id: card_ids) if card_ids.present?
result = result.open unless include_closed_cards?
result = result.by_engagement_status(engagement_status) if engagement_status.present?