3

I have an association:

has_many :regions_deployed, -> { where(taggings: { scope: 'deployed' }) },
:through => :taggings, :source => :choice_filter, :source_type => "Region"

This usually works, except when it is used in the joins clause of a named scope, chained to other named scopes that also join on taggings. Then Postgres aliases the table name taggings, but the where(taggings: { scope: 'deployed' } does not reflect that alias. How can I specify a dynamic table name inside where?

I think this question is closely related, but can't get it: Join the same table twice with conditions

Community
  • 1
  • 1
thebenedict
  • 2,539
  • 3
  • 20
  • 29

0 Answers0