I have a self-referencing association:
class EventAttendee < ApplicationRecord
belongs_to :initial_attendee, class_name: "EventAttendee", foreign_key: :initial_attendee_id
And using the pg_search gem I am trying to write a pg_search_scope to match against the event_attendee records and also the (self-associated) initial_attendee records (which are also actually event_attendee records). As far as I can tell, this should work:
pg_search_scope :search,
against: [:last_name, :first_name, :email],
associated_against: {initial_attendee: [:last_name, :first_name, :email]}
But it doesn't -- it just returns the matching regular event_attendee records, but not any that match the associated initial_attendee records. Any ideas about why this isn't working and how I can get this to work? I actually have another search scope for a different standard belongs_to association in that same model which is working great. Is it something about the self-referential association?