Problems with file_field


#1

Hello everyone

My rails app can upload images, and add the image path and name to the
database. But when i use very similar code to edit that entry by
uploading a different picture to replace the original, no changes take
place, can anyone see where i am going wrong?

The form that adds the image (in new.rhtml)

<p>Thumbnail <br /> <%= file_field "product", "thing" %></p>
The model that handels it

[code=]class Product < ActiveRecord::Base
belongs_to :department

def thing=(picture_field)
self.thumbnail = picture_field.original_filename
# need 'public' or image_tag in front of images for webrick
File.open("public/images/#{picture_field.original_filename}", "w") {

|f| f.write(picture_field.read) }
end

end[/code]
The controller method is the default scaffold generated.

But when i copy the code from the new.rhtml, to edit.rhtml, and i try to
upload an image, nothing happens!!

Anyone have any idea what i have messed up?