Skip to content

Share reverse chronological order scope #256

@potomak

Description

@potomak

There's a common use case where we sort tomatoes by creation date.

@dalpo suggested to create something like this:

scope :sorted_desc, -> { order_by([[:created_at, :desc], [:_id, :desc]]) }

I wanted to create such a scope, but I didn't find a good name for it. sorted_desc is not descriptive enough.

reverse_chronological_order is too long.

latest_first or freshest_first (🍅), but they have first in them that seem like a selection of the first element.

created_at_desc, but it wouldn't include the second sorting condition on _id.

See #255 (review).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions