Rails find by condition <p>Just wondering if there is any function that allows to do that:</p> <pre> MyModel.find_by_conditon(method_a - method_b > 0)</pre> <p> <code>MyModel.class</code></p> <pre> def method_a next_service_date.to_i end def method_b last_service_date.to_i end </pre> <pre> def next_service_date service_date.present? ? calculated_time_estimation : row_time_estimation end def calculated_time_estimation service_date + calculated_service_period end def calculated_service_period case(service_frequency_period) when 'Year' service_frequency_number.to_i.year when 'Month' service_frequency_number.to_i.month when 'Week' service_frequency_number.to_i.day * 7 when 'Day' service_frequency_number.to_i.day end end </pre> <p><code>service_frequency_number</code>, <code>service_frequency_period</code>, <code>service_date</code> are attributes for MyModel</p>