From 19791272b6e3b7777a58e3f06ebf253a199c3402 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 14 Feb 2020 17:06:53 +0900 Subject: [PATCH] Avoid "PG::AmbiguousColumn: ERROR: column reference "confirmed_at" is ambiguous" Proposal.joins(speakers: :user).confirmed => ActiveRecord::StatementInvalid (PG::AmbiguousColumn: ERROR: column reference "confirmed_at" is ambiguous) --- app/models/proposal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 123987e82..a1e48e5c8 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -44,7 +44,7 @@ class Proposal < ApplicationRecord scope :accepted, -> { where(state: ACCEPTED) } scope :waitlisted, -> { where(state: WAITLISTED) } scope :submitted, -> { where(state: SUBMITTED) } - scope :confirmed, -> { where('confirmed_at IS NOT NULL') } + scope :confirmed, -> { where.not(confirmed_at: nil) } scope :soft_accepted, -> { where(state: SOFT_ACCEPTED) } scope :soft_waitlisted, -> { where(state: SOFT_WAITLISTED) }