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)
[code=] <p>Thumbnail <br />
<%= file_field "product", "thing"
%></p>[/code]
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?
--
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---