Hi, I trying to do an upload form, bu the file_field doesnt seem to work as it should. I can't access the datafile properties...
#form <% form_for @student, :url => { :action => "upload_file",:id=>@student.id }, :multipart => true do |f|%> <%= file_field 'upload', 'datafile' %> <%= submit_tag "Upload" %> <% end%> #method 1 def upload_file student = Student.find(params[:id]) student.data_files << DataFile.save(params[:upload]) student.save redirect_to :edit end #Method 2 def self.save(upload) name = upload['datafile'].original_name puts name directory = "public/data" # create the file path path = File.join(directory, name) # write the file File.open(path, "wb") { |f| f.write(upload['datafile'].read) } self end #Error undefined method `original_name' for "iPhone intro.pdf":String Greg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.