0
Rails 4. Sqlite3 DB(用於開發)。如何在Rails中控制連接記錄的順序4
我的模型看起來是這樣的:
class Group < ActiveRecord::Base
has_many :memberships
has_many :people, through: :memberships
has_many :notes, as: :notable
scope :with_active_members, -> { joins(people: [:role]).where(people: {active: true}).uniq }
end
我用它是這樣的:
@groups = Group.with_active_members.order("groups.position")
的加入可以工作得很好。但我想按字母順序排列人員記錄。要非常清楚,我不要想要由他們的相關人員排序組。我希望這些小組按照他們的position
字段進行排序,但我希望按字母順序排列關聯的人員集合。這可以通過ORM完成嗎?