From ba5f659bb3066dc8a70eaab469bba1b1398919a9 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 29 Dec 2023 05:55:50 -0500 Subject: [PATCH] Use shorter attribute query methods in `Announcement` (#28474) --- app/models/announcement.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/announcement.rb b/app/models/announcement.rb index 2cd7c1d5ed..83a8d3682c 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -28,8 +28,8 @@ class Announcement < ApplicationRecord has_many :announcement_reactions, dependent: :destroy validates :text, presence: true - validates :starts_at, presence: true, if: -> { ends_at.present? } - validates :ends_at, presence: true, if: -> { starts_at.present? } + validates :starts_at, presence: true, if: :ends_at? + validates :ends_at, presence: true, if: :starts_at? before_validation :set_published, on: :create @@ -46,7 +46,7 @@ class Announcement < ApplicationRecord end def time_range? - starts_at.present? && ends_at.present? + starts_at? && ends_at? end def mentions