I have this association in the Project
model of a Rails 3.2 application:
has_many :pledges, conditions: { paid: true }
At one place, I need all unpaid pledges. Besides the two obvious solutions (defining another association with paid: false
condition or finding the pledges with Pledge.where...
), is it possible to drop the conditions on the fly?
Something similar to:
project.pledges.unscoped.where(paid: false) # does not work since the link to project is also lost
project.pledges.where(paid: false) # no good since it does "paid=t AND paid=f"