About string error for upload file in rails 2.1

hello:
I have code for upload image file to server file system.This works
in rails
1.2.3.But in rails 2.1,it gets an error.
The following is the important code:
In a view:
<%form_for :user,:url=>{:action=>“register”},:html=>{:multipart=>true}
do |f|-%>

照片 <%=f.file_field "file"-%>

<%end-%> ############################# In a model: class User < ActiveRecord::Base validates_format_of :photo,:with=>%r{\.(jpg|png|gif)$}i, :message=>"å›¾ç‰‡æ ¼å¼ä¸æ­£ç¡®" def file=(file_field) File.open("#{RAILS_ROOT}/public/images/users/#{file_field.original_filename}","wb+") { |i| i.write(file_field.read)} self.photo="/images/users/"+file_field.original_filename end end ############################## In a controller: class LoginController < ApplicationController def register @user=User.new(params[:user]) if params[:user]&&@user.save flash[:register]="#{@user.name}已创建" redirect_to :action=>"upanel" else render :action=>"register" end end end ####################### when i submit the form,i get the following error: undefined method `original_filename' for "":String ############ how do i make the upload code work?

sorry,i have resolved this problem.
File.open("#{RAILS_ROOT}/public/images/users/#{file_field.original_filename}",“wb+”)
The “wb+” should be “wb”.