Project

General

Profile

Actions

Improvement #501

open

Avoid warnings on Enumeration.system, Group.sorted, and User.sorted

Added by liaham over 3 years ago. Updated over 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Compatible Redmine Version:

Description

W, [2021-08-31T09:17:26.837276 #86]  WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2021-08-31T09:17:27.044029 #86]  WARN -- : Creating scope :sorted. Overwriting existing method Group.sorted.
W, [2021-08-31T09:17:27.050843 #86]  WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.

Here is an example of how to fix those warnings:

class Reservation < ApplicationRecord
  enum status: [:pending, :requested, :confirmed, :checked_out, :returned, :cancelled]

  singleton_class.undef_method :open # hide Kernel.open, avoiding a warning when defining scope :open
  scope :open, -> { where(status: [:pending, :requested]) }
end

Source: https://github.com/rails/rails/issues/31234

Actions #1

Updated by liaham over 3 years ago

  • Tracker changed from Bug to Improvement
Actions

Also available in: Atom PDF