diff options
author | hellekin <hellekin@cepheide.org> | 2020-10-08 16:51:30 +0200 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2020-10-08 16:59:33 +0200 |
commit | 8f691b566ffbc79f1d2d7a3f67d8607cc03a789c (patch) | |
tree | fb17d5bb8b725778fe24d8c9e685467ebb48da79 /app/models/taxonomy.rb | |
parent | 46071bc467cd6d671c2cfe53ffe5d9eedcb96ae3 (diff) | |
download | incommon-map-8f691b566ffbc79f1d2d7a3f67d8607cc03a789c.tar.gz |
Add model foundation for classifications
Taxonomy > Category > Section
This commit adds models for it.
https://doc.incommon.cc/#classifications
Diffstat (limited to 'app/models/taxonomy.rb')
-rw-r--r-- | app/models/taxonomy.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/taxonomy.rb b/app/models/taxonomy.rb new file mode 100644 index 0000000..0810fc0 --- /dev/null +++ b/app/models/taxonomy.rb @@ -0,0 +1,17 @@ +class Taxonomy < ApplicationRecord + # Universally Unique Identifier :uuid + include UUIDParameter + + default_scope { order(created_at: :asc) } + + belongs_to :agent + has_many :categories, -> { order(rank: :asc) }, dependent: :destroy, inverse_of: :taxonomy + has_many :sections, -> { order(rank: :asv) }, through: :categories + + validates :name, + presence: true, + uniqueness: true, + length: 3..64 + validates :summary, + length: 0..136 +end |