2013-11-13 07:10:03 -05:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: broadcast_messages
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# message :text default(""), not null
|
|
|
|
# starts_at :datetime
|
|
|
|
# ends_at :datetime
|
|
|
|
# alert_type :integer
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
|
2013-11-12 06:47:28 -05:00
|
|
|
class BroadcastMessage < ActiveRecord::Base
|
|
|
|
attr_accessible :alert_type, :ends_at, :message, :starts_at
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|