0

I've just integrated cloudinary into my rails project and created a view to allow the user to upload an image file.

In my controller I have:

def update
    @painting = Painting.find(params[:id])

if params[:image].present?
  preloaded = Cloudinary::PreloadedFile.new(params[:image])
  raise "Invalid upload signature" if !preloaded.valid?
  @painting.image = preloaded.identifier
end

    if @painting.update(painting_params)
        redirect_to @painting
    else 
        render 'edit'
    end
end

In my view:

    <%= cl_image_upload_tag(:image) %>

So once the user edits a painting, they can upload the image which will be stored in the @painting model and then it will be saved. After uploading the image, I check cloudinary and find that no image was uploaded. In addition the @painting model has a nil entry for the :image attribute.

Can't see what I'm doing wrong.

user1686342
  • 1,265
  • 1
  • 18
  • 24

1 Answers1

0

Please have a look at the developer tools at the view page, and check whether you have any reported errors there. Specifically, might be related to the jQuery library not being properly included.

You should try to have a look at the sample project. Specifically, https://github.com/cloudinary/cloudinary_gem/blob/master/samples/photo_album/app/views/photos/new_direct.html.erb#L20

Itay Taragano
  • 1,901
  • 1
  • 11
  • 12