Finding Uploads In Parameters On Submit In Rails
I'm trying to figure out which of these parameters contains an uploaded file. This code works
params[:upload].each do | uploaded_image | if (uploaded_image != "") # do something with uploaded_image; end end
but my way of moving through the parameters (with the , for instance) seems wrong. What's the right way to do this?
You will be getting the images one at a time using that do loop, so you don't need to index into the array.
params[:upload].each do | uploaded_image | unless uploaded_image.blank? # do something with uploaded_image; end end
.blank? will cover nil or empty
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?