improve achievement management and and views
This commit is contained in:
@@ -19,4 +19,6 @@ class WowAchievement < ApplicationRecord
|
||||
|
||||
validates :name, presence: true
|
||||
validates :achievement_id, presence: true, uniqueness: true
|
||||
|
||||
scope :base_achievements, -> { where(prerequisite_achievement: nil) }
|
||||
end
|
||||
|
||||
@@ -4,8 +4,16 @@ class WowAchievementCategory < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name
|
||||
|
||||
belongs_to :parent_category, class_name: 'WowAchievementCategory', optional: true
|
||||
has_many :child_categories,
|
||||
class_name: 'WowAchievementCategory',
|
||||
foreign_key: 'parent_category_id',
|
||||
dependent: :nullify,
|
||||
inverse_of: :parent_category
|
||||
has_many :wow_achievements, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :category_id, presence: true, uniqueness: true
|
||||
|
||||
scope :base_categories, -> { where(parent_category: nil) }
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ class WowAchievementCriterium < ApplicationRecord
|
||||
dependent: :destroy,
|
||||
inverse_of: :parent_criterium
|
||||
belongs_to :parent_criterium, class_name: 'WowAchievementCriterium', optional: true
|
||||
|
||||
has_many :completed_wow_achievement_criteria, dependent: :destroy
|
||||
has_many :wow_characters, through: :completed_wow_achievement_criteria
|
||||
|
||||
|
||||
Reference in New Issue
Block a user