Rails 4: dynamic table name possible in `where` on` has_many: through`?
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 used in a joins
named scope clause that is bound to other named scopes that are also bound to taggings
. Postgres then aliases the table name taggings
, but where(taggings: { scope: 'deployed' }
does not reflect that alias. How to specify dynamic table name inside where
?
I think this question is closely related, but it can't get it: Including the same table twice with conditions
+3
source to share
No one has answered this question yet
See similar questions:
or similar: