From 8244b59be0986b02260e30c4fc9521af8adcb4f9 Mon Sep 17 00:00:00 2001 From: Anton Katunin Date: Tue, 9 Jul 2024 13:16:19 +1000 Subject: [PATCH] Fix specs --- lib/active_interaction/extras/nested_attributes.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/active_interaction/extras/nested_attributes.rb b/lib/active_interaction/extras/nested_attributes.rb index edc6fbd..bca9e84 100644 --- a/lib/active_interaction/extras/nested_attributes.rb +++ b/lib/active_interaction/extras/nested_attributes.rb @@ -4,14 +4,16 @@ module ActiveInteraction::Extras::NestedAttributes concern :InputsExtension do def normalize(inputs) - @base.class.nested_attribute_options.each do |attribute, options| - alias_name = "#{attribute}_attributes" - next if !inputs.key?(alias_name) && !inputs.key?(alias_name.to_sym) + if @base.class.respond_to? :nested_attribute_options + @base.class.nested_attribute_options.each do |attribute, options| + alias_name = "#{attribute}_attributes" + next if !inputs.key?(alias_name) && !inputs.key?(alias_name.to_sym) - value = inputs[alias_name] || inputs[alias_name.to_sym] - value = @base.class.process_nested_collection(value, options) + value = inputs[alias_name] || inputs[alias_name.to_sym] + value = @base.class.process_nested_collection(value, options) - inputs[attribute.to_s] = value + inputs[attribute.to_s] = value + end end super