I have this association:
has_many :foo_participators, through: :foos, source: :user, conditions: "foos.state = 'completed'"
Rails tells me:
DEPRECATION WARNING: The following options in your Bar.has_many :foo_participators declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
Is this possible with my association?
Figured this out right after I asked the question. For some reason I hadn't tried putting the lambda first -- doing so works perfectly.
has_many :foo_participators, ->{where "foos.state = 'completed'"}, through: :foos, source: :user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With