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. -- 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 -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Eric! that worked! Cheers, Xavi. -- 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 -~----------~----~----~----~------~----~------~--~---