Hi Guys,
It’s my first suggestion/post here so go easy on me
So recently I’ve found myself writing scopes or functions like this:
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
``
I would like to suggest the addition of these functions to ActiveRecord so all ActiveRecord Objects can inherit these functions (If time-stamps are enabled).
If this feature is something people are interested in, I’d love the opportunity to dev this as I want to contribute and give back to the Rails community.
Let me know what you guys think
Will