Extract records which satisfy a model function in Rails
问题 I have following method in a model named CashTransaction . def is_refundable? self.amount > self.total_refunded_amount end def total_refunded_amount self.refunds.sum(:amount) end Now I need to extract all the records which satisfy the above function i.e records which return true . I got that working by using following statement: CashTransaction.all.map { |x| x if x.is_refundable? } But the result is an Array . I am looking for ActiveRecord_Relation object as I need to perform join on the