[refs #531] small refactoring

This commit is contained in:
Alexander Machehin 2012-06-25 20:31:41 +06:00
parent d5a6b47be3
commit 9625e1bb4f
1 changed files with 1 additions and 3 deletions

View File

@ -132,10 +132,8 @@ class User < ActiveRecord::Base
def best_role target
roles = target_roles(target)
return 'admin' if roles.include? 'admin'
return 'writer' if roles.include? 'writer'
return 'reader' if roles.include? 'reader'
return nil if roles.count == 0
%w(admin writer reader).each {|role| return role if roles.include?(role)}
raise "unknown user #{self.uname} roles #{roles}"
end