I love Paperclip and I've used it successfully in a few projects now.
I have a new project with slightly different requirements and I'm a
bit stuck.
Basically, I need my paperclip attachment to come from a temp file
instead of a form field.
I'm creating an image of text (via ImageMagick) and I want that image
to be the attachment.
How would I do this?
Here's code from my model that I've tried (with no success):
after_create :make_image
has_attached_file :image,
:styles => {:thumb=> "100x100#", :small => "150x150>", :medium
=> "250x250>", :large => "625x300>" },
:path => ":rails_root/public/
uploads/:attachment/:id/:style_:basename.:extension",
:url => "/uploads/:attachment/:id/:style_:basename.:extension"
def make_image
file = File.join(Dir.tmpdir, "#{
self.id}_image.png")
`convert -background lightblue -fill blue -font Arial -pointsize
72 label:some-text #{file}`
io = File.read(file)
self.image = io
end