From 69e3e67c858d0b20be6081e69e54b4abc72f7657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 23 Oct 2019 18:05:25 +0200 Subject: [PATCH] Avoid "Overwriting existing method open" warning In Ruby, the Kernel class defined the `open` method, which is available for (almost) every object. So creating a scope with the name `open` generates a warning indicating we are overwriting the existing `open` method. While this warning is pretty much harmless and we could ignore it, it generates a lot of noise in the logs. So I'm "undefining" the method before generating the scope, so we don't get the warning all the time. --- app/models/budget.rb | 1 + app/models/legislation/process.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/budget.rb b/app/models/budget.rb index 8d6023fcb..614d124c0 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -55,6 +55,7 @@ class Budget < ApplicationRecord scope :reviewing_ballots, -> { where(phase: "reviewing_ballots") } scope :finished, -> { where(phase: "finished") } + class << self; undef :open; end scope :open, -> { where.not(phase: "finished") } def self.current diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index c07edadd6..443994506 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -54,6 +54,7 @@ class Legislation::Process < ApplicationRecord validates :background_color, format: { allow_blank: true, with: CSS_HEX_COLOR } validates :font_color, format: { allow_blank: true, with: CSS_HEX_COLOR } + class << self; undef :open; end scope :open, -> { where("start_date <= ? and end_date >= ?", Date.current, Date.current) } scope :active, -> { where("end_date >= ?", Date.current) } scope :past, -> { where("end_date < ?", Date.current) }