How do i update an image with Attachment_Fu?

Hi, making the switchover from the file_upload plugin to the pretty
awesome Attachment_Fu plugin to handle all my image uploads,

so far going good, but stuck on two things?

Any ideas how i can basically update an image & delete an image ?

can’t seem to find any good examples anywhere,

appreciate it,

John.

it should support User.update_attributes(params[:user])

where user.rb has the has_attachment in the model and inside
params[:user]
is an “uploaded_data” file field.

Adam

On Dec 12, 2007 9:44 AM, John G.
[email protected]

Thanks for that,

here’s my working [delete] button on the show page

<%= button_to “Delete Photo”, :action => “destroy”, :id => @image %>

and my destroy method…

def destroy
Image.find(params[:id]).destroy
redirect_to :action => ‘list’
end

and here’s the [edit] page…

<% form_for(:image, :url => {:id => @image, :action => “update” }, :html
=> { :multipart => true }) do |f| -%>

Replace Photo:
<%= image_tag @image.public_filename(:thumb) %>
with <%= f.file_field :uploaded_data %>

<%= f.submit 'Save Changes' %> or <%= button_to_function "Go Back", "window.location='/image/show/#{@image.id}'" %>

<% end -%>

and the method…

def edit
@image = Image.find(params[:id])
end

def update
@image = Image.find(params[:id])
if @image.update_attributes(params[:image])
flash[:notice] = ‘Photo was successfully updated.’
redirect_to :action => ‘show’, :id => @image
else
flash[:notice] = ‘Something awful just happend!’
render :action => ‘edit’
end
end

all work, just thought i should post them, so glad i got that out of the
way, thanks AD