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.
加载中,请稍侯......
精彩评论