I have the following associations in my Survey model:
has_many :survey_group_lists, -> { order 'sequence ASC, group_id ASC' }
has_many :groups, through: :survey_group_lists
I want to add where cluase to :groups association so it will return only active groups. I've tried something like this:
has_many :groups, -> { where(active: true) }, through: :survey_group_lists
but it returns me an error:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "slide_groups"
What I'm doing wrong?
Edit: I'm using Rails 5.