ruby on rails - ActiveRecord: order by records that have an association first, then those that don't -


i have app photos. photos belong_to collection, don't.

i'd create scope sort query such photo belongs_to collection (ie collection_id != nil) shown first, , rest of photos (ie collection_id == nil)

how that?

thanks!

can orderby("collection_id")? nils should grouped together.


Comments