From 8f691b566ffbc79f1d2d7a3f67d8607cc03a789c Mon Sep 17 00:00:00 2001 From: hellekin Date: Thu, 8 Oct 2020 16:51:30 +0200 Subject: Add model foundation for classifications Taxonomy > Category > Section This commit adds models for it. https://doc.incommon.cc/#classifications --- app/models/section.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/models/section.rb (limited to 'app/models/section.rb') diff --git a/app/models/section.rb b/app/models/section.rb new file mode 100644 index 0000000..a9d163e --- /dev/null +++ b/app/models/section.rb @@ -0,0 +1,10 @@ +class Section < ApplicationRecord + belongs_to :category + has_ony :taxonomy, through: :category + + acts_as_list column: :rank, scope: :category + + validates :name, + uniqueness: { scope: category_id }, + length: 3..64 +end -- cgit v1.2.3