开发者

Paperclip add a image in the code

开发者 https://www.devze.com 2023-02-07 08:59 出处:网络
I wish to use the paperclip gem to add an image that I am retrieving from an开发者_如何学编程 API for my user model using code.

I wish to use the paperclip gem to add an image that I am retrieving from an开发者_如何学编程 API for my user model using code.

How can I attach an image manually using code, rather than passing in parameters from a submitted form ?


If your model object is @bar, image field is called :logo and you want to attach foo.jpg...

@bar[:logo] = File.open('foo.jpg') should work. Or am I misunderstanding the question?

You'd need to initialize your paperclip attachments in a similar way if you were populating from seed data, for example.

0

精彩评论

暂无评论...
验证码 换一张
取 消