diff options
author | David Gay <david@davidgay.org> | 2021-05-22 14:32:38 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-22 14:32:44 -0400 |
commit | 88bd4f77db3a4372c118a9faef613615db66bc52 (patch) | |
tree | c0ad67b0cdde98e58199052198c9b4f1c45a85f2 /app/models | |
parent | 2dd5608409f0a506cd2a682107d9be302cec8079 (diff) |
Titles
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character.rb | 3 | ||||
-rw-r--r-- | app/models/chat_room.rb | 2 | ||||
-rw-r--r-- | app/models/title.rb | 3 | ||||
-rw-r--r-- | app/models/title_award.rb | 6 |
4 files changed, 13 insertions, 1 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 41dc951..73d2c4b 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,6 +1,9 @@ class Character < ApplicationRecord belongs_to :user belongs_to :activity, optional: true + has_many :title_awards + has_many :titles, through: :title_awards + belongs_to :active_title, class_name: "Title", optional: true has_one :hearth has_many :character_items has_many :learned_activities diff --git a/app/models/chat_room.rb b/app/models/chat_room.rb index 17e3f19..f1e9a24 100644 --- a/app/models/chat_room.rb +++ b/app/models/chat_room.rb @@ -14,7 +14,7 @@ class ChatRoom < ApplicationRecord } def self.accessible_to(user) - all.select { |x| x.accessible_to?(user) } + all.select { |x| x.accessible_to?(user) && x.gid != "achievement" } end def accessible_to?(user) diff --git a/app/models/title.rb b/app/models/title.rb new file mode 100644 index 0000000..c80a1d1 --- /dev/null +++ b/app/models/title.rb @@ -0,0 +1,3 @@ +class Title < ApplicationRecord + validates :gid, :name, presence: true +end diff --git a/app/models/title_award.rb b/app/models/title_award.rb new file mode 100644 index 0000000..ef74958 --- /dev/null +++ b/app/models/title_award.rb @@ -0,0 +1,6 @@ +class TitleAward < ApplicationRecord + belongs_to :title + belongs_to :character + + validates :character_id, uniqueness: { scope: :title_id } +end |