gitlab-org--gitlab-foss/app/models/broadcast_message.rb

29 lines
697 B
Ruby
Raw Normal View History

# == Schema Information
#
# Table name: broadcast_messages
#
# id :integer not null, primary key
# message :text not null
# starts_at :datetime
# ends_at :datetime
# created_at :datetime
# updated_at :datetime
# color :string(255)
# font :string(255)
#
class BroadcastMessage < ActiveRecord::Base
include Sortable
2015-12-01 23:53:44 +00:00
validates :message, presence: true
validates :starts_at, presence: true
2015-12-01 23:53:44 +00:00
validates :ends_at, presence: true
2015-12-01 23:53:44 +00:00
validates :color, allow_blank: true, color: true
validates :font, allow_blank: true, color: true
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end
end