diff options
author | hellekin <hellekin@cepheide.org> | 2020-10-09 10:24:06 +0200 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2020-10-09 10:24:06 +0200 |
commit | f48ce2f4c934fde3862cdad593eececc7a567d61 (patch) | |
tree | d2c874f8ebf4686d07052fa333032c04ef49e861 /app/models/agent.rb | |
parent | 31850c6ca118b7828dbaa3ad1a87dab4287718f5 (diff) | |
download | incommon-map-f48ce2f4c934fde3862cdad593eececc7a567d61.tar.gz |
Add Classifications and Resource validations
- Turn `has_and_belongs_to_many` into `has_many :through`: now,
resources and sections are related through Classifications.
- Refactor usage of jsonb column to use ActiveRecord validations
- Attention! store_accessor:
NOTE: If you are using structured database data types (eg. PostgreSQL hstore/json, or MySQL 5.7+ json) there is no need for the
serialization provided by .store. Simply use .store_accessor instead to generate the accessor methods. Be aware that these
columns use a string keyed hash and do not allow access using a symbol.
NOTE: The default validations with the exception of uniqueness will work. For example, if you want to check for uniqueness with
hstore you will need to use a custom validation to handle it.
https://api.rubyonrails.org/classes/ActiveRecord/Store.html
Diffstat (limited to 'app/models/agent.rb')
-rw-r--r-- | app/models/agent.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/agent.rb b/app/models/agent.rb index 07e0b8e..6264ba3 100644 --- a/app/models/agent.rb +++ b/app/models/agent.rb @@ -2,4 +2,15 @@ class Agent < ApplicationRecord has_many :agencies has_many :members, through: :agencies, source: :user has_many :resources + has_many :taxonomies + has_many :categories, through: :taxonomies + has_many :sections, through: :categories + + def to_param + uuid + end + + def to_s + name + end end |