Hey Everybody,
This is the only way I’ve been able to get my file
upload to work:
class Item < ActiveRecord::Base
def file=(upload)
@file=upload
end
def after_create
File.open(“public/items/#{self.id}.jpg”, “w”) {
|f| f.write(@file.read) }
end
end
The upload form has “file_field ‘item’, ‘file’, …”.
I’ve tried using self.file (causes a stack error), and
@id (empty). It just feels wrong mixing class and
instance vars ;). Am I missing something?
Thanks,
csn
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/