Rails zamów zero ostatnie

Photo.order('collection_id DESC NULLS LAST') # NULLs come last
Wide-eyed Wolverine