From 2cb31d20a76a0ffe5935a725a953bfcc6e0ad9e7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 26 Apr 2016 01:41:38 +0200 Subject: [PATCH] Added order for User.of_role(). --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8bf589b8f..34fed0745 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -460,12 +460,12 @@ returns def self.of_role(role, group_ids = nil) roles_ids = Role.where(active: true, name: role).map(&:id) if !group_ids - return User.where(active: true).joins(:users_roles).where('roles_users.role_id IN (?)', roles_ids) + return User.where(active: true).joins(:users_roles).where('roles_users.role_id IN (?)', roles_ids).order('users.updated_at DESC') end User.where(active: true) .joins(:users_roles) .joins(:users_groups) - .where('roles_users.role_id IN (?) AND users_groups.group_ids IN (?)', roles_ids, group_ids) + .where('roles_users.role_id IN (?) AND users_groups.group_ids IN (?)', roles_ids, group_ids).order('users.updated_at DESC') end =begin