I have a table with a column priority_n
. Pretend there are 5 items in that table. Two with nil
as priority_n
, and the other three have 1
, 2
, 3
.
I'd like to do a where(priority_n: nil).order(published_at: :desc)
combined with where.not(priority_n: nil).order(priority_n: :asc)
. I want the nil
ones at the beginning of the active record relations, and then the prioritized ones after them. Is there a way to do this?
If I could figure out how to do this in SQL then I could do it in rails.