Sha256: 30a53e5bd822d3073bd96ef3ee1f8f6560c3cbfb0c24db2dac6c88b919b556ed
Contents?: true
Size: 781 Bytes
Versions: 90
Compression:
Stored size: 781 Bytes
Contents
module Fields::SuperSelectSupport extend ActiveSupport::Concern def assign_select_options(strong_params, attribute) attribute = attribute.to_s # We check for nil here because an empty array isn't `present?`, but we want to assign empty arrays. if strong_params.key?(attribute) && !strong_params[attribute].nil? # filter out the placeholder inputs that arrive along with the form submission. strong_params[attribute] = strong_params[attribute].select(&:present?) end end def create_model_if_new(id) if id.present? unless /^\d+$/.match?(id) id = yield(id).id.to_s end end id end def create_models_if_new(ids) ids.map do |id| create_model_if_new(id) do yield(id) end end end end
Version data entries
90 entries across 90 versions & 1 rubygems