app/models/announcement.rb
def starts_before_end_time
    return unless start_at.present? && end_at.present? && start_at > end_at

    errors.add(:start_at, 'must be before end_at')
  end
# Validates the start_at time is before the end_at time
# (otherwise it would never appear)
#
Validates the start_at time is before the end_at time
(otherwise it would never appear)
Validates the start_at time is before the end_at time ( otherwise it would never appear )
def starts_before_end_time
    return unless start_at.present? && end_at.present? && start_at > end_at
    errors.add(:start_at, 'must be before end_at')
  end
def starts_before_end_time return unless start_at . present? && end_at . present? && start_at > end_at errors . add ( :start_at , 'must be before end_at' ) end
Validates the start_at time is before the end_at time
(otherwise it would never appear)
Validates the start_at time is before the end_at time ( otherwise it would never appear )