Rails already has default_scope for situations like this

class Model < ApplicationRecord
  default_scope { order("created_at) }
end

Would this be sufficient?
On Thu, Sep 6, 2018 at 6:24 PM Tekin Suleyman <te...@tekin.co.uk> wrote:
>
>
> On 30 Aug 2018, at 12:15, Tekin Suleyman <te...@tekin.co.uk> wrote:
>
> Hiya,
>
> I’m working on a project that uses PostgreSQL UUIDs as primary keys. I’d like 
> to make the first and last finder methods behave more predictably without 
> having to resort to explicit order calls everywhere or setting default 
> scopes. Having looked through the code for the finder methods, one option 
> that has presented itself is to make the default sort order configurable so a 
> column other than primary_key can be specified. I’m up for working on a patch 
> for this but thought I’d post here for thoughts before I got stuck in. I’m 
> imagining something like this to specify it:
>
>
>   class Model < ApplicationRecord
>     default_order_column :created_at
>   end
>
>
> Any thoughts?
>
> Thanks in advance,
>
> Tekin
>
>
>
>
> Hiya,
>
> Does anyone have any thoughts as to whether this change is likely to be 
> accepted? I’m more than happy to work up a PR.
>
>
> --
> 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