diff --git a/app/models/principal.rb b/app/models/principal.rb index 9ec0f6ff8..37d2a545d 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -33,6 +33,11 @@ class Principal < ActiveRecord::Base } def <=>(principal) - self.to_s.downcase <=> principal.to_s.downcase + if self.class.name == principal.class.name + self.to_s.downcase <=> principal.to_s.downcase + else + # groups after users + principal.class.name <=> self.class.name + end end end diff --git a/app/models/user.rb b/app/models/user.rb index e9c58bcc5..4cfa2b47b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -214,11 +214,6 @@ class User < Principal def self.find_by_mail(mail) find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase]) end - - # Sort users by their display names - def <=>(user) - self.to_s.downcase <=> user.to_s.downcase - end def to_s name