I'm displaying Authors on a page (Rails view) like so:
Author.where(featured: true).where.not(username: nil).order(:priority, :name)
However I have recently added a new model Photographer and I would like to combine the photographers with the authors and sort them similarly. They share most of the same columns.
I've tried:
combined = (Author.where(featured: true).where.not(username: nil) + Photographer.where(featured: true).where.not(username: nil))
combined.order(:priority, name)
=> NoMethodError (undefined method `order' for #<Array:0x00005573bc2ab3b0>)
combined.sort_by {|item| [item.priority, item.name]}
=> ArgumentError (comparison of Array with Array failed)
One caveat is that in some cases priority would be nil. So in that event it should order by name instead.
Any help is appreciated!