From: Nadeesha Meththananda Date: 2007-11-13T20:01:57+09:00 Subject: File Uploading codes I used the following codes found in the net to use to write a file to upload the files. down are the codes i have used. but still i did not able to get the correct coding. so if somebody know where i have gone wrong pls reply. ###################### IN the View #############################3

Name:
<%= text_field "person", "name" %>

Picture:

#################The controller:########################## class AddressbookController < ApplicationController def new # not really needed since the template doesn't rely on any data end def create post = Post.save(@params["person"]) # Doesn't this mean post is a File object? # post.id is a bad idea in this case... redirect_to :action => "show", :id => post.id end end ######### the model ################### class Post < ActiveRecord::Base def self.save(person) f = File.new("pictures/#{person['name']}/picture.jpg", "wb") f.write params[:picture].read f.close end in the uploading it gives a error like this undefined local variable or method `params' for Post:Class so i did some modification as f.write params[:picture].read line to f.write (@params[:picture].read) so the code woke properly, but still it gives a error saying You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] SO IF SOMEBODY KNOW HOW TO OVER COME THIS PROBLEM PLS REPLY -- Posted via http://www.ruby-forum.com/.