Carrierwave multiple uploads fails with mount_uploaders
I'm using a new way to add multiple files with carrierware as describle here: https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads
When I try save the object I got this error:
Invalid JSON text: "Invalid value." at position 1 in value (or column) '--- - photo1.jpg - photo2.jpg '.
Using: Rails 4.2.1 MySQL 5.7.10 Ruby 2.2.2
Does anyone know what can it be?
I fix it migrating my project from MySQL to PostgreSQL.
I had the same problem here on mysql and rails 4 with Carrierwave multiple upload files(images here), I added this to my model.rb:
serialize :menu_images, JSON
mount_uploaders :menu_images, AvatarUploader
of course :menu_images is the column name for multiple files. It fixed the problem, no need to change the database.
You were probably reading the carrierwave documentation on the master branch on github.
If you have the following in your Gemfile:
Then at the time of writing you would have carrierwave 0.11.2 installed.
The mount_uploaders method is not available in this version, it is currently on the master branch.
If you want to you want to use this method, you should add this line to your Gemfile instead:
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
This will fix your issue.