Remove file_column image in a form?

Hi all,
I’ve got the following problem. I’ve got a form for a Project object.
Three of the fields are images that are attributes of the Projecte
object. I use the file_column plugin to upload them.

<% form_tag ({action => ‘create’}, :multipart => true do %>
.
.
<%= file_column_field ‘project’, ‘image’ %>
.
.
<% end %>

The thing is that I want to let the user delete an image he might have
uploaded before he presses the submit button. Is that possible? For what
I’ve read, the way to delete the image is to set projecte.image=nil
before a project.save (which is done when the form is submitted). How
could I let the user do that before the submit? Any ideas would be
appreciated!
Thanks in advance,

Xavi.

Xavier Guardiola wrote:

The thing is that I want to let the user delete an image he might have
uploaded before he presses the submit button. Is that possible? For what
I’ve read, the way to delete the image is to set projecte.image=nil
before a project.save (which is done when the form is submitted). How
could I let the user do that before the submit? Any ideas would be
appreciated!

I generally put a checkbox on the form (a normal checkbox not tied to
the model or anything. I.E.

<%= check_box_tag ‘remove_image’ %>

Then in my “update” action I put the following:

@project = Project.find params[:id]
@project.attributes = params[:project]
@project.image = nil if params[:remove_image]
if @project.save
flash[:notice] = “Project #{@project} sucessfully updated”
redirect_to projects_path
else
render :action => 'edit
end

So basically we just have an extra param to flag the image for removal.

Eric

Thanks Eric! that worked!
Cheers,

Xavi.