class SomeModel < ActiveRecord::Base
scope :created_before, ->(timestamp) { where('created_at < ?', timestamp) }
end
class SomeModel < ActiveRecord::Base
def self.updated_before(time) where('updated_at < ?', time) end
def self.updated_after(time) where('updated_at > ?', time) end
def self.updated_between(start_time, end_time) updated_after(start_time).updated_before(end_time) end
end
Your updated_between can easily be accomplished by passing a date range to the where method. ie.start..start+1.day
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
You can add an ApplicationModel to your rails 4 app as well. It's just a new default base model in rails 5.