This support forum is no longer in use. Please use the Cloudinary Community at https://community.cloudinary.com/ to receive assistance from other members of the community and from Cloudinary's support team. For account-specific questions or if you believe that you've encountered a bug, please contact the Cloudinary team directly via the "submit a request" option on this support site.

ruby on rails: duplicate images uploaded with each form submission

Comments

4 comments

  • Avatar
    Alexander Rousmaniere

    I tried adjusting the function to this

     

    def get_cloudinary_url

    #get from cloudinary the secure_url and add it to the item.

    _ if self.changed?_

    _ upload = Cloudinary::Uploader.upload(self.picture_link.to_s)_

    _ self.secure_url = upload["secure_url"]_

    _ self.public_id = upload["public_id"] _

    _ end_

    _ end_

     

     

    but still duplicate images are uploaded.

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    Can you please try the following and let me know if this helps? :

    if self._picture_link__changed?

    _ ...
    _

    You might want to consider using our CarrierWave integration to simplify this process.

    0
    Comment actions Permalink
  • Avatar
    Alexander Rousmaniere

    I had tried the _changed method, but I think that returns an array, not a boolean -- or maybe it was something else causing problems.

    In the end, I used:

     

    if self.picture_link_was != self.picture_link

    ...... and so far this is working

     

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    The _changed? method is a boolean. The .changes  method returns an array. See:  http://api.rubyonrails.org/classes/ActiveModel/Dirty.html

    However, I'm glad it works for you now :)

    0
    Comment actions Permalink

Post is closed for comments.