From 36fe8fbc6d064c738a6ce090407dd24fb0e10f99 Mon Sep 17 00:00:00 2001 From: Juan de Dios Herrero Date: Fri, 7 Jun 2013 18:26:06 +0200 Subject: [PATCH] Added role scopes to roleable --- app/models/user.rb | 3 --- lib/roleable.rb | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 94d5c619d..866ac7b19 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,9 +61,6 @@ class User < ActiveRecord::Base # This is just used to pass some information into the serializer attr_accessor :notification_channel_position - scope :admins, -> { where(admin: true) } - scope :moderators, -> { where(moderator: true) } - scope :staff, -> { where("moderator or admin ") } scope :blocked, -> { where(blocked: true) } # no index module NewTopicDuration diff --git a/lib/roleable.rb b/lib/roleable.rb index d4cef18cb..1e39f9f44 100644 --- a/lib/roleable.rb +++ b/lib/roleable.rb @@ -3,6 +3,12 @@ require 'active_support/concern' module Roleable extend ActiveSupport::Concern + included do + scope :admins, -> { where(admin: true) } + scope :moderators, -> { where(moderator: true) } + scope :staff, -> { where("moderator or admin ") } + end + # any user that is either a moderator or an admin def staff? admin || moderator