guts guts - 1 year ago 77
Ruby Question

Create paperclip attachment from rmagick image

I have a problem to find a way to save an image created with RMagick in a paperclip attachment.

imageList ="images/apple.gif", "images/overlay.png")
picture = imageList.flatten_images

I am in a model that have an attached file

has_attached_file :picture,
:url => ...,
:path => ...

and i just want my image returned by imageList.flatten_images to be saved as the picture of my model.

Does anyone know how to do it easily please?


Answer Source

Let's see if that's what you need

picture = imageList.flatten_images
file ='my_picture.jpg')
YourModel.create(:picture => file, ...)

Change YourModel with the model you are using...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download