add achievement management

This commit is contained in:
2021-08-15 16:45:49 +02:00
parent 2552a78d15
commit 39ebeea387
27 changed files with 435 additions and 26 deletions

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class WowAchievement < ApplicationRecord
extend Mobility
translates :name, :description, :reward_description
belongs_to :wow_achievement_category, optional: true
belongs_to :wow_achievement_criterium, optional: true
belongs_to :prerequisite_achievement, class_name: 'WowAchievement', optional: true
has_one :next_achievement,
class_name: 'WowAchievement',
foreign_key: 'prerequisite_achievement_id',
dependent: :nullify,
inverse_of: :prerequisite_achievement
has_many :completed_wow_achievements, dependent: :destroy
has_many :wow_characters, through: :completed_wow_achievements
validates :name, presence: true
validates :achievement_id, presence: true, uniqueness: true
end