How to order Posts by the draft
status and then by title ignoring any other status.
class Post < ApplicationRecord
# attribute :title # attribute :status # :draft, :published, :other def self.ordered
order("status = 'draft' DESC, title ASC") endend
Post.ordered
# -> [ # <layout: post.liquid
title: "Draft A",
# status: "draft">,
# <layout: post.liquid
title: "Draft B",
# status: "draft">,
# <layout: post.liquid
title: "A Title",
# status: "other">,
# <layout: post.liquid
title: "B Title",
# status: "published">,
# ]