code: def store_associations_on_object(object, attribute, associations)
        values = associations.collect do |assoc|
          assoc.internal.blank? ? assoc.value : assoc.internal
        end
  
        # Clean up values
        values.compact!
        case values.length
          when 0 then values = nil
          when 1 then values = values.first
        end
  
        object.send("#{attribute}=", values)
      end
docs: Stores all association data on the object at the given attribute.
   Associations with internal data use that instead of value.  If only one
   association is present, it is extracted from the array and stored as-is.