gitlab-org--gitlab-foss/app/models/broadcast_message.rb
Dmitriy Zaporozhets 3a21c904dd
Use strong params for 5 more models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-26 15:00:09 +03:00

27 lines
766 B
Ruby

# == Schema Information
#
# Table name: broadcast_messages
#
# id :integer not null, primary key
# message :text not null
# starts_at :datetime
# ends_at :datetime
# alert_type :integer
# created_at :datetime
# updated_at :datetime
# color :string(255)
# font :string(255)
#
class BroadcastMessage < ActiveRecord::Base
validates :message, presence: true
validates :starts_at, presence: true
validates :ends_at, presence: true
validates :color, format: { with: /\A\#[0-9A-Fa-f]{3}{1,2}+\Z/ }, allow_blank: true
validates :font, format: { with: /\A\#[0-9A-Fa-f]{3}{1,2}+\Z/ }, allow_blank: true
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end
end