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.
This commit is contained in:
@@ -55,6 +55,7 @@ class Budget < ApplicationRecord
|
|||||||
scope :reviewing_ballots, -> { where(phase: "reviewing_ballots") }
|
scope :reviewing_ballots, -> { where(phase: "reviewing_ballots") }
|
||||||
scope :finished, -> { where(phase: "finished") }
|
scope :finished, -> { where(phase: "finished") }
|
||||||
|
|
||||||
|
class << self; undef :open; end
|
||||||
scope :open, -> { where.not(phase: "finished") }
|
scope :open, -> { where.not(phase: "finished") }
|
||||||
|
|
||||||
def self.current
|
def self.current
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class Legislation::Process < ApplicationRecord
|
|||||||
validates :background_color, format: { allow_blank: true, with: CSS_HEX_COLOR }
|
validates :background_color, format: { allow_blank: true, with: CSS_HEX_COLOR }
|
||||||
validates :font_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 :open, -> { where("start_date <= ? and end_date >= ?", Date.current, Date.current) }
|
||||||
scope :active, -> { where("end_date >= ?", Date.current) }
|
scope :active, -> { where("end_date >= ?", Date.current) }
|
||||||
scope :past, -> { where("end_date < ?", Date.current) }
|
scope :past, -> { where("end_date < ?", Date.current) }
|
||||||
|
|||||||
Reference in New Issue
Block a user