I am obviously doing something wrong when implementing the rubyonrials
wiki code for uploading a file.
I don’t seem to be getting the actual file object included with the
form, as it complains about trying to call read on a string object.
How do I get the actual file that was uploaded?
Here is my code:
Controller
def auto
if request.post?
@sched = Schedule.new
@sched.automate(params[:schedule])
end
end
Model
def automate(schedule)
File.open(“schedule_store/#{schedule[‘filename’]}”, “w”) { |f|
f.write(schedule[‘filename’].read) }
end
View
Schedule: