add Axis, Category and Subject
This commit is contained in:
18
app/models/axis.rb
Normal file
18
app/models/axis.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: axes
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# name :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_axes_on_name (name) UNIQUE
|
||||
#
|
||||
class Axis < ApplicationRecord
|
||||
has_many :subjects
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
end
|
||||
18
app/models/category.rb
Normal file
18
app/models/category.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: categories
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# name :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_categories_on_name (name) UNIQUE
|
||||
#
|
||||
class Category < ApplicationRecord
|
||||
has_many :subjects
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
end
|
||||
28
app/models/subject.rb
Normal file
28
app/models/subject.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: subjects
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# name :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# axis_id :bigint not null
|
||||
# category_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_subjects_on_axis_id (axis_id)
|
||||
# index_subjects_on_category_id (category_id)
|
||||
# index_subjects_on_name (name) UNIQUE
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (axis_id => axes.id)
|
||||
# fk_rails_... (category_id => categories.id)
|
||||
#
|
||||
class Subject < ApplicationRecord
|
||||
belongs_to :category
|
||||
belongs_to :axis
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
end
|
||||
Reference in New Issue
Block a user