better user listing

This commit is contained in:
jomo
2014-06-29 12:21:46 +02:00
parent abcce299fb
commit 3e0e5878e6
2 changed files with 10 additions and 2 deletions

View File

@@ -8,7 +8,13 @@ class UsersController < ApplicationController
if params[:role].downcase == "staff"
@users = User.all.select {|u| u.role >= Role.get(:mod) }
else
@users = User.where(role: Role.get(params[:role]))
if role = Role.get(params[:role])
@users = User.where(role: role)
else
flash[:alert] = "role '#{params[:role]}' does not exist!"
redirect_to users_path
return
end
end
else
@users = User.where.not(id: User.first.id) #Remove first user