The method call inside where looks non idiomatic to me. Much cleaner if you
simply define scopes with:

Users.where('updated_at > ?' 6.months.ago)

On Sat, Feb 13, 2016 at 11:59 AM, Radan Skoric <[email protected]>
wrote:

> Nice suggestion but I think it should be changed to not be so oriented to
> time fields. Those are just simple comparison operations.
>
> This seems equally readable to me while having the benefit of making sense
> with any ordered type:
>
> User.where(updated_at: greater_than(6.months.ago))
> Post.where(updated_at: less_than(1.year.ago))
>
>
> On Saturday, 13 February 2016 01:23:09 UTC+1, Jacob Smith wrote:
>>
>> Often times, doing a query involves time based methods: "All users
>> updated within the last 6 months", "All posts older than 1 year", etc.
>>
>> My proposal is for an ActiveRecord helper method that would allow those
>> queries to be written in a way similar to:
>>
>> Users.where(updated_at: within(6.months))
>>
>> Posts.where(updated_at: older_than(1.year))
>>
>> Obviously that syntax may have to change to work with ActiveRecord/Arel.
>>
>> I have been a Rails developer for about 3 years, so I'm very comfortable
>> with Rails and ActiveRecord, though I have never contributed before. I am
>> open to any and all suggestions or comments. I looked and didn't see any
>> similar proposals in Github issues, though I may have missed something. If
>> there is positive feedback on this, I would love to take a stab at it and
>> let that be my first contribution back to Rails and, with that, if you have
>> any advice on actual implementation considerations, I would love to hear
>> those ideas, too!
>>
>> Thanks,
>> Jacob
>>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wael Khobalatte

-- 
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 [email protected].
To post to this group, send email to [email protected].
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