SORT_ORDER = %w[under_review submitted published] # Rails 7 Post.in_order_of(:state, SORT_ORDER).all # Older versions Post.all.sort_by{ |post| SORT_ORDER.index(post.state) }