From 3f734a03897deb16fe4a661b575a45306535ff95 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 9 Jul 2023 22:39:59 -0700 Subject: [PATCH] Revert "Grid model object updates" This reverts commit 70e820b781884792b0f3d9b485a0d01d24e485a1. --- app/models/grid_character.rb | 8 +++----- app/models/grid_summon.rb | 2 -- app/models/grid_weapon.rb | 8 +++++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/models/grid_character.rb b/app/models/grid_character.rb index 6fc5783..09d6e8d 100644 --- a/app/models/grid_character.rb +++ b/app/models/grid_character.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class GridCharacter < ApplicationRecord - has_one :object, class_name: 'Character', foreign_key: :id, primary_key: :character_id - belongs_to :awakening, optional: true belongs_to :party, counter_cache: :characters_count, @@ -89,9 +87,9 @@ class GridCharacter < ApplicationRecord private def add_awakening - return unless awakening.nil? - - self.awakening = Awakening.where(slug: 'character-balanced').sole + if self.awakening.nil? + self.awakening = Awakening.where(slug: "character-balanced").sole + end end def check_value(property, type) diff --git a/app/models/grid_summon.rb b/app/models/grid_summon.rb index f2a1afc..c62a33b 100644 --- a/app/models/grid_summon.rb +++ b/app/models/grid_summon.rb @@ -5,7 +5,6 @@ class GridSummon < ApplicationRecord counter_cache: :summons_count, inverse_of: :summons validates_presence_of :party - has_one :object, class_name: 'Summon', foreign_key: :id, primary_key: :summon_id validate :compatible_with_position, on: :create validate :no_conflicts, on: :create @@ -24,7 +23,6 @@ class GridSummon < ApplicationRecord party.summons.find do |grid_summon| return unless grid_summon.id - grid_summon if summon.id == grid_summon.summon.id end end diff --git a/app/models/grid_weapon.rb b/app/models/grid_weapon.rb index ab8e3fd..459e450 100644 --- a/app/models/grid_weapon.rb +++ b/app/models/grid_weapon.rb @@ -6,8 +6,6 @@ class GridWeapon < ApplicationRecord inverse_of: :weapons validates_presence_of :party - has_one :object, class_name: 'Weapon', foreign_key: :id, primary_key: :weapon_id - belongs_to :weapon_key1, class_name: 'WeaponKey', foreign_key: :weapon_key1_id, optional: true belongs_to :weapon_key2, class_name: 'WeaponKey', foreign_key: :weapon_key2_id, optional: true belongs_to :weapon_key3, class_name: 'WeaponKey', foreign_key: :weapon_key3_id, optional: true @@ -80,6 +78,10 @@ class GridWeapon < ApplicationRecord # Checks if the weapon should be a mainhand before saving the model def is_mainhand - self.mainhand = position == -1 + if self.position == -1 + self.mainhand = true + else + self.mainhand = false + end end end