mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 06:01:12 +00:00
Every time a new track, event type or difficulty level is created, the color picker has a different color by default. Closes https://github.com/openSUSE/osem/issues/1077
18 lines
420 B
Ruby
18 lines
420 B
Ruby
class Track < ActiveRecord::Base
|
|
belongs_to :program
|
|
has_many :events, dependent: :nullify
|
|
|
|
before_create :generate_guid
|
|
validates :name, presence: true
|
|
validates :color, format: /\A#[0-9a-fA-F]{6}\z/
|
|
|
|
private
|
|
|
|
def generate_guid
|
|
guid = SecureRandom.urlsafe_base64
|
|
# begin
|
|
# guid = SecureRandom.urlsafe_base64
|
|
# end while Person.where(:guid => guid).exists?
|
|
self.guid = guid
|
|
end
|
|
end
|