-
Notifications
You must be signed in to change notification settings - Fork 482
/
parent_levels_child_level.rb
40 lines (39 loc) · 1.57 KB
/
parent_levels_child_level.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
# == Schema Information
#
# Table name: parent_levels_child_levels
#
# id :integer not null, primary key
# parent_level_id :integer not null
# child_level_id :integer not null
# position :integer
# kind :string(255) default("sublevel"), not null
#
# Indexes
#
# index_parent_levels_child_levels_on_child_level_id (child_level_id)
# index_parent_levels_child_levels_on_parent_level_id (parent_level_id)
#
# This class allows a level to store an ordered list of child levels. Each
# instance of this class represents an individual parent-child relationship
# between a pair of levels. Initially, this functionality will be used to
# represent sublevels within LevelGroup, BubbleChoice, and Lesson Extras levels.
#
# The number of columns on this model's table should be few as possible, and
# should not be specific to the kind of parent-child relationship or to the
# parent level type. Ideally, we would only ever add the following two columns
# to this model:
#
# 1. the `kind` column, in order to support contained levels and project
# template levels
#
# 2. a `properties` column, which the parent level would need to know how to
# managed, based on its level type and this model's `kind`
#
# For design details, see:
# https://docs.google.com/document/d/10mqXBdkFo5nWhjGWJO6D_NMl4Qg74qb7P6Fdvb2P7sc/edit?usp=sharing
#
class ParentLevelsChildLevel < ActiveRecord::Base
belongs_to :parent_level, class_name: 'Level'
belongs_to :child_level, class_name: 'Level'
validates_uniqueness_of :child_level, scope: :parent_level
end