Saving a file ... what's missing

I’m trying to do the classic file upload to a directory in my file
system (public/drawings). I have the following:

In the view:
<%= file_field ( “drawing”, “drawingfile” ) %>

In the controller, in addition to the usual .save, I have
@drawing.save_drawing(params[:drawing][:drawingfile])

In the model, I have

def save_drawing(inputfile)
	if inputfile.original_filename

File.open("#{RAILS_ROOT}/public/drawings/#{inputfile.original_filename}",
“wb”) {
|f| f.write(inputfile.read) }
end
inputfile
end

The save_drawing routine is almost verbatim from the HowToUploadAFile
document. It IS creating a file in the right location in the file
system, but no data is being written to it (e.g. a zero length file).

What am I missing?

Thanks in advance
—Michael

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs