2013-11-13 07:10:03 -05:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: broadcast_messages
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
2014-04-09 08:05:03 -04:00
|
|
|
# message :text not null
|
2013-11-13 07:10:03 -05:00
|
|
|
# starts_at :datetime
|
|
|
|
# ends_at :datetime
|
|
|
|
# alert_type :integer
|
2014-04-09 08:05:03 -04:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2013-12-09 00:34:51 -05:00
|
|
|
# color :string(255)
|
|
|
|
# font :string(255)
|
2013-11-13 07:10:03 -05:00
|
|
|
#
|
|
|
|
|
2013-11-12 06:47:28 -05:00
|
|
|
class BroadcastMessage < ActiveRecord::Base
|
2015-02-05 17:20:55 -05:00
|
|
|
include Sortable
|
|
|
|
|
2013-11-12 06:47:28 -05:00
|
|
|
validates :message, presence: true
|
2013-11-12 07:28:12 -05:00
|
|
|
validates :starts_at, presence: true
|
|
|
|
validates :ends_at, presence: true
|
2013-11-12 08:08:20 -05:00
|
|
|
|
2014-06-04 04:04:36 -04:00
|
|
|
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
|
2013-12-19 13:11:01 -05:00
|
|
|
|
2013-11-12 08:08:20 -05:00
|
|
|
def self.current
|
|
|
|
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
|
|
|
|
end
|
2013-11-12 06:47:28 -05:00
|
|
|
end
|