parent
3b4f6c1a27
commit
baba6aa9e9
@ -0,0 +1,9 @@
|
||||
class CourseStage < ApplicationRecord
|
||||
belongs_to :course, counter_cache: true
|
||||
|
||||
has_many :course_stage_shixuns, -> { order("course_stage_shixuns.position ASC") }, dependent: :destroy
|
||||
has_many :shixuns, :through => :course_stage_shixuns
|
||||
|
||||
validates :name, length: { maximum: 60 }
|
||||
validates :description, length: { maximum: 300 }
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class CourseStageShixun < ApplicationRecord
|
||||
belongs_to :course, counter_cache: :stages_count, counter_cache: :shixuns_count
|
||||
belongs_to :course_stage
|
||||
belongs_to :shixun, counter_cache: :shixuns_count
|
||||
end
|
@ -0,0 +1,13 @@
|
||||
class CreateCourseStages < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :course_stages do |t|
|
||||
t.references :course, index: true
|
||||
t.string :name
|
||||
t.text :description
|
||||
t.integer :position
|
||||
t.integer :shixuns_count
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class CreateCourseStageShixuns < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :course_stage_shixuns do |t|
|
||||
t.references :course, index: true
|
||||
t.references :course_stage, index: true
|
||||
t.references :shixun, index: true
|
||||
t.integer :position
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseStageShixun, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseStage, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in new issue