Decode and update the image attribute - carrierwave gem

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Decode and update the image attribute - carrierwave gem



Save the decoded image in AWS path, I am using carrierwave gem



I have a base64 encoded image in my controller. I would like to decode the image and want to save the reference in database and Save the image in AWS server



In my model I have the decoding and assigning option like this. But I am Unable to save the image parameter in database. I am getting error unpermitted parameter image. But I have included it in strong parameters


mount_uploader :image, ImageUploader

def decode_base64_image(encoded_file)
decoded_file = Base64.decode64(encoded_file)
file = Tempfile.new(['image','.png'])
file.binmode
file.write decoded_file

self.image = file

end


class ImageUploader < CarrierWave::Uploader::Base


storage :file

def store_dir
"uploads/#model.class.to_s.underscore/#mounted_as/#model.id"
end
end





What is the error message? Can you please add the code of ImageUploader class?
– MrShemek
Aug 6 at 13:58


ImageUploader





The Uploader looks fine. Since the problem is with the unpermitted parameter, can you show the controller (for strong params)? Or just put a binding pry in a method that checks params :)
– MrShemek
Aug 6 at 14:24









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard