So, Members have many subscriptions. A member is canceled if the last subscription canceled_at is not nil. But I can't seem to get the query to work right, to find all members with presently canceled subscriptions.
I'm doing this in the member model
scope :canceled, includes(:subscriptions).
where('subscriptions.canceled_at IS NOT NULL')
but it returns for users who have previously canceled subscriptions too. I need to use limit or something like that, I have the relation defined as
has_many :subscriptions, :order => "subscriptions.created_at DESC", :dependent => :destroy
so i can just work offf the .first, but not sure how to apply that logic to the class scope like that.