Reputation: 8172
To my model, I need to upload two files. One is an image and the other is a pdf file. I upload the image first and then the app take me to a different page to set the title, description, etc. In that page I need to upload the second file. But it does not work. Here's how I set the uploaders in the model :
mount_uploader :filename, SubmitUploader
mount_uploader :modelrelease, ModelreleaseUploader
The first file is uploading. The second is not. Also note that in the edit screen I edit multiple records at a time. Here's the controller :
def uploadscheck
@submits = Submit.update(params[:submits].keys, params[:submits].values)
if @submits.empty?
redirect_to root_url
else
@rejected = current_user.rejected
render 'uploaded'
end
end
I don't get any errors. It simply won't upload. The filed which should have the pdf file have an empty string.
Upvotes: 4
Views: 139
Reputation: 1702
It could be a strong parameters problem, where you are trying to access the value directly and it doesn't give you the value.
As it is an array or hash, treat it as a scalar value, as shown here. See if you have file information on
params.permit(submits: [])
or
params.require(:submits).permit!
Upvotes: 6