开发者

Paperclip add a image in the 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜