Paperclip with Cloudinary #3878
Replies: 7 comments 3 replies
-
I know that solidus-demo, which is the repo for the demo of Solidus, is using Cloudinary, maybe there's something there you can use to make it work, this configuration for example. |
Beta Was this translation helpful? Give feedback.
-
Thank you, I'll start reading the code, see what I can do |
Beta Was this translation helpful? Give feedback.
-
Everything is working fine from the cloudinary-paperclip gem side, the problem is that I'm getting a This is due to the trailing slash in the begging of the :path value in the has_attchement hash, but the thing is I can't override this hash, I tried doing the same thing they did the demo app with the initializer file
however only the Here's the full trace in case you can help
|
Beta Was this translation helpful? Give feedback.
-
Maybe there's something else in the initialization process that is updating |
Beta Was this translation helpful? Give feedback.
-
For anyone else facing this in the future this is how I fixed it: Copy the PaperclipAttachment module into app/models/spree/image/ rename it, edit the has_attachment hash then in the spree initializer edit the configuration of
|
Beta Was this translation helpful? Give feedback.
-
That works, but it would be good to know the underlying cause to make customizations like this easier. |
Beta Was this translation helpful? Give feedback.
-
I stumbled into this a year or so ago on a side project and solved it with a decorator: module Paperclip::Storage::CloudinaryDecorator
# Currently, `paperclip-cloudinary` will raise an error
# if you check for the existence of an attachment that
# hasn't been defined on the record yet. This is because
# it immediately queries Cloudinary for existence, instead
# of first checking if the attachment exists locally.
def exists?(*)
present? && super
end
Paperclip::Storage::Cloudinary.prepend self
end IIRC, Paperclip itself must be aware of an existing attachment in order for it to determine what the |
Beta Was this translation helpful? Give feedback.
-
Hi, I've been trying to configure paperclip to store the images on cloudinary
I installed the Cloudinary-Paperclip gem, and configured my API keys
Then I needed to tell paperclip to store on cloudinary but whenever I try to do so the configuration is overriden by the Solidus defaults. I created a decorator for the
Spree::Image::PaperclipAttachment
class and added the following:there are no errors, and I used byebug to make sure the file is being used but still the images are being stored locally, so next I tried adding to the
Spree::Image.attachment_definitions[:attachment]
hash by usingSpree::Image.attachment_definitions[:attachment][:storage] = :cloudinary
I tried adding that in the initializer file, and within the decorator, yet still the images are saved on the device and when I runSpree::Image.attachment_definitions[:attachment]
in the rails console I getshowing that the configuration is still not being overridden
Beta Was this translation helpful? Give feedback.
All reactions