From 579f2bf7b8f9fbff790062d71391dacc21182eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Aldrin=20Wikstr=C3=B6m?= Date: Thu, 15 May 2014 15:47:49 +0200 Subject: [PATCH] Fix suspended scope :non_suspended should check if suspension is <= NOW, else one could end up in neither group. --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9eae13b2b49..2b3b25d0cd9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -88,7 +88,7 @@ class User < ActiveRecord::Base scope :blocked, -> { where(blocked: true) } # no index scope :not_blocked, -> { where(blocked: false) } # no index scope :suspended, -> { where('suspended_till IS NOT NULL AND suspended_till > ?', Time.zone.now) } # no index - scope :not_suspended, -> { where('suspended_till IS NULL') } + scope :not_suspended, -> { where('suspended_till IS NULL OR suspended_till <= ?', Time.zone.now) } # excluding fake users like the community user scope :real, -> { where('id > 0') }