Sha256: 1c76c347a89cbf82428dd2dee6791edd2daec57500d15fa4c0aa2a81752beae2
Contents?: true
Size: 982 Bytes
Versions: 86
Compression:
Stored size: 982 Bytes
Contents
module Lalala::ExtActionDispatch::MultiFileUpload private def normalize_parameters(value) value = super(value) if Hash === value value.each do |key, v| value[key] = correct_assets_hash_nesting(key, v) end end return value end def correct_assets_hash_nesting(key, value) unless key.to_s.ends_with?("_attributes") return value end unless Hash === value return value end if value.size == 0 return value end last_id = value.keys.sort_by(&:to_i).last last_id = "#{last_id}" unless /^\d+$/ === last_id return value end assets = value[last_id].try(:[], "asset") unless Array === assets return value end unless assets.all?{ |i| ActionDispatch::Http::UploadedFile === i } return value end assets.each do |file| value[last_id] = { "asset" => file }.with_indifferent_access last_id.succ! end return value end end
Version data entries
86 entries across 86 versions & 1 rubygems