You can add an ApplicationModel to your rails 4 app as well. It's just a
new default base model in rails 5.

On Jul 22, 2016 4:18 AM, "Will Hennessey" <will.hennessey...@gmail.com>
wrote:

> Hey Tom,
>
> Thanks for the suggestion, I'm currently using Rails 4.2.5 so I'm not
> familiar with Rails 5 and ApplicationModel.
> I'll look into upgrading to Rails 5 and implementing the idea in
> the ApplicationModel :)
>
> On Friday, 22 July 2016 01:01:25 UTC+1, Tom Prats wrote:
>>
>> Hey Will,
>>
>> In Rails 5 all your models will inherit from ApplicationModel, which can
>> then be the only place you'd need that code for all your models to use.
>>
>> Thanks,
>> Tom
>> On Thu, Jul 21, 2016 at 5:15 PM Andrew Kaspick <akas...@gmail.com> wrote:
>>
>>> Your updated_between can easily be accomplished by passing a date range
>>> to the where method. ie.start..start+1.day
>>>
>>> On Jul 21, 2016 5:06 PM, "Will Hennessey" <will.hen...@gmail.com> wrote:
>>>
>>>> Hi Guys,
>>>>
>>>> It's my first suggestion/post here so go easy on me :p
>>>> 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
>>>>
>>>> --
>>>> 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 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 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-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to