-
Notifications
You must be signed in to change notification settings - Fork 482
/
standalone_video.rb
53 lines (47 loc) · 1.28 KB
/
standalone_video.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# == Schema Information
#
# Table name: levels
#
# id :integer not null, primary key
# game_id :integer
# name :string(255) not null
# created_at :datetime
# updated_at :datetime
# level_num :string(255)
# ideal_level_source_id :integer
# solution_level_source_id :integer
# user_id :integer
# properties :text(65535)
# type :string(255)
# md5 :string(255)
# published :boolean default(FALSE), not null
# notes :text(65535)
#
# Indexes
#
# index_levels_on_game_id (game_id)
# index_levels_on_name (name)
#
class StandaloneVideo < Level
serialized_attrs %w(
encrypted_teacher_markdown
skip_dialog
skip_sound
)
before_validation do
self.skip_dialog = true
self.skip_sound = true
end
validate :has_video_key?
def has_video_key?
unless video_key.present?
errors.add :video_key, :blank
end
end
def icon
'fa-video-camera'
end
def self.create_from_level_builder(params, level_params)
create!(level_params.merge(user: params[:user], game: Game.standalone_video, level_num: 'custom'))
end
end