I'm still quite new to RoR and I am having trouble uploading files to
a file system. I have been following this tutorial:
Peak Obsession :
1.2.1. The simplest thing that could possibly work
But when I try to save a file I get "You have a nil object when you
didn't expect it!
The error occurred while evaluating nil.read"
In this very simple example its the controller that does all the work:
def save
File.open("#{RAILS_ROOT}/public/images/testWorked.jpg", "wb") do |
f>
f.write(@params['picture_file'].read)
end
I want to save the files to the file system and not to a database. fto
set the enctype I used multipart => true and the html output is set to
enctype="multipart/form-data" so that should be fine.
Is the ruby code:
File.open("#{RAILS_ROOT}/public/images/testWorked.jpg", "wb") do |
f>
f.write(@params['picture_file'].read)
incorrect for dealing with file uploads?
I'll see if i can find a plugin that allows saves to the file system.
Give attachment_fu by Rick Olson a try - it's very good and allows you
to save to the file system, database, or Amazon S3. There is also
'uploadcolumn'.