lib/avo/fields/belongs_to_field.rb in avo-3.10.7 vs lib/avo/fields/belongs_to_field.rb in avo-3.10.8

- old
+ new

@@ -193,28 +193,28 @@ end foreign_key.to_sym end - def fill_field(model, key, value, params) - return model unless model.methods.include? key.to_sym + def fill_field(record, key, value, params) + return record unless record.methods.include? key.to_sym if polymorphic_as.present? valid_model_class = valid_polymorphic_class params[:"#{polymorphic_as}_type"] - model.send(:"#{polymorphic_as}_type=", valid_model_class) + record.send(:"#{polymorphic_as}_type=", valid_model_class) # If the type is blank, reset the id too. if valid_model_class.blank? - model.send(:"#{polymorphic_as}_id=", nil) + record.send(:"#{polymorphic_as}_id=", nil) else - model.send(:"#{polymorphic_as}_id=", params["#{polymorphic_as}_id"]) + record.send(:"#{polymorphic_as}_id=", params["#{polymorphic_as}_id"]) end else - model.send("#{key}=", value) + record.send(:"#{key}=", value) end - model + record end def valid_polymorphic_class(possible_class) types.find do |type| type.to_s == possible_class.to_s