Module: Miscellany::JsonUploads
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/miscellany/controller/json_uploads.rb
Instance Method Summary collapse
-
#params ⇒ Object
This hackery allows using JSON params along with file-uploads On the frontend, use MultiPart form data, and add _parameters as an entry.
Instance Method Details
#params ⇒ Object
This hackery allows using JSON params along with file-uploads On the frontend, use MultiPart form data, and add _parameters as an entry
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/miscellany/controller/json_uploads.rb', line 7 def params if @_params.nil? params_obj = @_params = super phash = params_obj.instance_variable_get(:@parameters) if phash[:_parameters].present? json_layer = JSON.parse(phash.delete(:_parameters)) shared_keys = phash.keys & json_layer.keys main_layer = phash.slice(*shared_keys) merge_params(json_layer, main_layer) phash.merge!(json_layer) end end @_params end |