From 9625e1bb4f68e74dd2bcbf09ad273d323de05fd8 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 25 Jun 2012 20:31:41 +0600 Subject: [PATCH] [refs #531] small refactoring --- app/models/user.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ddf0fc3f1..7bbd42965 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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