debian-mirror-gitlab/app/models/broadcast_message.rb

30 lines
720 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
# == 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
2015-04-26 12:48:37 +05:30
include Sortable
2015-12-23 02:04:40 +05:30
validates :message, presence: true
2014-09-02 18:07:02 +05:30
validates :starts_at, presence: true
2015-12-23 02:04:40 +05:30
validates :ends_at, presence: true
2014-09-02 18:07:02 +05:30
2015-12-23 02:04:40 +05:30
validates :color, allow_blank: true, color: true
validates :font, allow_blank: true, color: true
2014-09-02 18:07:02 +05:30
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end
end