From 01f523f1658bdac92cfd2d1bfeb6999db2f23b46 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 3 Feb 2020 15:12:21 +0000 Subject: [PATCH] Rails 6: Fix deprecation warning "Class level methods will no longer inherit scoping" (#32911). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@19490 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 4 ++-- lib/redmine/acts/positioned.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index a837697a4..76f479bcd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -634,7 +634,7 @@ class User < Principal Project.unscoped do return @project_ids_by_role if @project_ids_by_role - group_class = anonymous? ? GroupAnonymous : GroupNonMember + group_class = anonymous? ? GroupAnonymous.unscoped : GroupNonMember.unscoped group_id = group_class.pluck(:id).first members = Member.joins(:project, :member_roles). @@ -970,7 +970,7 @@ class AnonymousUser < User def validate_anonymous_uniqueness # There should be only one AnonymousUser in the database - errors.add :base, 'An anonymous user already exists.' if AnonymousUser.exists? + errors.add :base, 'An anonymous user already exists.' if AnonymousUser.unscoped.exists? end def available_custom_fields diff --git a/lib/redmine/acts/positioned.rb b/lib/redmine/acts/positioned.rb index bb7f80524..f8134c6de 100644 --- a/lib/redmine/acts/positioned.rb +++ b/lib/redmine/acts/positioned.rb @@ -66,7 +66,7 @@ module Redmine h[column] = yield(column) h end - self.class.where(condition_hash) + self.class.unscoped.where(condition_hash) end def set_default_position