diff options
author | hellekin <hellekin@cepheide.org> | 2020-10-08 16:59:55 +0200 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2020-10-08 16:59:55 +0200 |
commit | 00ac912be46d858379fb5685b7290fe8d60001ef (patch) | |
tree | 6eb7c1cb2e75d58f40d41479267dfa2e381c678f /app/models/category.rb | |
parent | 12cd55048f1357a3e3dc384db37b9f4edb6819d7 (diff) | |
parent | 8f691b566ffbc79f1d2d7a3f67d8607cc03a789c (diff) | |
download | incommon-map-00ac912be46d858379fb5685b7290fe8d60001ef.tar.gz |
Merge branch 'taxonomies'
Diffstat (limited to 'app/models/category.rb')
-rw-r--r-- | app/models/category.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 0000000..b8c49f1 --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,14 @@ +class Category < ApplicationRecord + belongs_to :taxonomy + has_many :sections, + -> { order(rank: :asc) }, + dependent: :destroy, + inverse_of: :category + + acts_as_list column: :rank, scope: :taxonomy + + validates :name, + presence: true, + uniqueness: { scope: :taxonomy_id }, + length: 3..64 +end |