Add new relationships to existing models

This commit is contained in:
Justin Edmund 2025-03-02 16:24:50 -08:00
parent a6bf326655
commit e0c38a60ba
3 changed files with 28 additions and 0 deletions

View file

@ -34,6 +34,16 @@ class Character < ApplicationRecord
}
}
has_many :character_skills,
primary_key: 'granblue_id',
foreign_key: 'character_granblue_id'
has_many :skills,
through: :character_skills
has_many :charge_attacks,
-> { where(owner_type: 'character') },
primary_key: 'granblue_id',
foreign_key: 'owner_id'
AWAKENINGS = [
{ slug: 'character-balanced', name_en: 'Balanced', name_jp: 'バランス', order: 0 },
{ slug: 'character-atk', name_en: 'Attack', name_jp: '攻撃', order: 1 },

View file

@ -34,6 +34,15 @@ class Summon < ApplicationRecord
}
}
has_many :summon_calls,
primary_key: 'granblue_id',
foreign_key: 'summon_granblue_id'
has_many :summon_auras,
primary_key: 'granblue_id',
foreign_key: 'summon_granblue_id'
has_many :skills,
through: :summon_calls
def blueprint
SummonBlueprint
end

View file

@ -36,6 +36,15 @@ class Weapon < ApplicationRecord
has_many :weapon_awakenings
has_many :awakenings, through: :weapon_awakenings
has_many :weapon_skills,
primary_key: 'granblue_id',
foreign_key: 'weapon_granblue_id'
has_many :skills,
through: :weapon_skills
has_many :charge_attacks,
-> { where(owner_type: 'weapon') },
primary_key: 'granblue_id',
foreign_key: 'owner_id'
SERIES_SLUGS = {
1 => 'seraphic',