Create paperclip attachment from rmagick image

前端 未结 3 1452
粉色の甜心
粉色の甜心 2021-01-04 20:04

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

imageList = Magick::ImageList.new
imageList.new(\"images/appl         


        
3条回答
  •  猫巷女王i
    2021-01-04 20:40

    Let's see if that's what you need

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

    Change YourModel with the model you are using...

提交回复
热议问题