Add validations to BroadcastMessage color and font

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-12-19 20:11:01 +02:00
parent e78c51f7cf
commit d1e8495890
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
2 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,9 @@ class BroadcastMessage < ActiveRecord::Base
validates :starts_at, presence: true
validates :ends_at, presence: true
validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end

View File

@ -21,11 +21,13 @@
.control-group.js-toggle-colors-container.hide
= f.label :color, "Background Color"
.controls
= f.text_field :color
= f.text_field :color, placeholder: "#AA33EE"
.light Hex values as 3 double digit numbers, starting with a # sign.
.control-group.js-toggle-colors-container.hide
= f.label :font, "Font Color"
.controls
= f.text_field :font
= f.text_field :font, placeholder: "#224466"
.light Hex values as 3 double digit numbers, starting with a # sign.
.control-group
= f.label :starts_at
.controls.datetime-controls