Sort members_list by roles
Setup
bundle exec rails db:drop
bundle exec rails db:create
bundle exec rails db:schema:load
bundle exec rails c
To test we'll need to add some users and roles
amy = FactoryBot.create(:user, first_name: 'amy')
betty = FactoryBot.create(:user, first_name: 'betty')
carly = FactoryBot.create(:user, first_name: 'carly')
project = Project.create!(title: 'project', creator: betty)
betty.add_role(:owner, project)
amy.add_role(:admin, project)
carly.add_role(:member, project)
GET /api/projects/1/members
. You'll see that carly is first because she is the latest active.
GET /api/projects/1/members?sort=oldest
. You'll see amy is first because she is the oldest.
GET /api/projects/1/members?sort=roles
. You'll see users sorted like: betty, amy, carly.
Edited by Anthony Shull