只是想知道是否有任何功能,可以這樣做:Rails的找到狀態
MyModel.find_by_conditon(method_a - method_b > 0)
MyModel.class
def method_a next_service_date.to_i end def method_b last_service_date.to_i end
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
service_frequency_number
,service_frequency_period
,service_date
是爲MyModel
您可以更好地瞭解您嘗試解決的問題嗎?問題和定義有點模糊。 last_service_date是否等同於service_date?另外如何定義row_time_estimate? – ashoda