From 4cf6516fe5461f35b3ea1f163071e64c97092854 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 13 Jan 2024 09:56:55 -0800 Subject: [PATCH] Allow PartiesController to accept nested attributes (#141) --- app/controllers/api/v1/parties_controller.rb | 15 ++++++++++++++- app/models/party.rb | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index c7c0ce6..7d1287c 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -395,7 +395,20 @@ module Api :chain_count, :guidebook1_id, :guidebook2_id, - :guidebook3_id + :guidebook3_id, + characters_attributes: [:id, :party_id, :character_id, :position, + :uncap_level, :transcendence_step, :perpetuity, + :awakening_id, :awakening_level, + { ring1: %i[modifier strength], ring2: %i[modifier strength], + ring3: %i[modifier strength], ring4: %i[modifier strength], + earring: %i[modifier strength] }], + summons_attributes: %i[id party_id summon_id position main friend + quick_summon uncap_level transcendence_step], + weapons_attributes: %i[id party_id weapon_id + position mainhand uncap_level element + weapon_key1_id weapon_key2_id weapon_key3_id + ax_modifier1 ax_modifier2 ax_strength1 ax_strength2 + awakening_id awakening_level] ) end end diff --git a/app/models/party.rb b/app/models/party.rb index a4f32db..5d71f4c 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -77,6 +77,10 @@ class Party < ApplicationRecord has_many :favorites, dependent: :destroy + accepts_nested_attributes_for :characters + accepts_nested_attributes_for :summons + accepts_nested_attributes_for :weapons + before_create :set_shortcode before_create :set_edit_key