Forum: Ruby on Rails paperclip - deleting a photo from a form

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78d56bb0f91c899d40f1767b3040d825?d=identicon&s=25 bingo bob (bingobob)
on 2008-10-09 15:34
Any tips as to how paperclip can be used to delete photos.

I mean that in my update view I show six browse buttons, all capable of
updating the photo that corresponds to that browse button (e.g. photo1
or photo2). That works, what if the user wants to delete one of those
photos, how do I do that?

bb
78d56bb0f91c899d40f1767b3040d825?d=identicon&s=25 bingo bob (bingobob)
on 2008-10-09 16:53
bingo bob wrote:
> Any tips as to how paperclip can be used to delete photos.
>
> I mean that in my update view I show six browse buttons, all capable of
> updating the photo that corresponds to that browse button (e.g. photo1
> or photo2). That works, what if the user wants to delete one of those
> photos, how do I do that?
>
> bb

Looking to find out what I need to do in my view and in my controller.
78d56bb0f91c899d40f1767b3040d825?d=identicon&s=25 bingo bob (bingobob)
on 2008-10-10 14:01
Anyone have any tips on this one? I suppose I may need an additional
action in my controller to cope with deletion of a particular photo and
then re-render the edit view..
78d56bb0f91c899d40f1767b3040d825?d=identicon&s=25 bingo bob (bingobob)
on 2008-10-12 10:02
For reference, here's the edit view for an advert, as I say, I'm trying
to integrate a fiunction that allows users to delete one of the photos
(1 to 6), any clues as to what i might do in this form / controller.


<h1>Editing advert</h1>

<div id="advert_images">

<%= render :partial => "images", :locals => { :advert => @advert } %>

</div>

<% form_for @advert, :html => { :multipart => true } do |f| %>

  <%= f.error_messages %>

<ul>
  <li><%= f.file_field :photo1%></li>
  <li><%= f.file_field :photo2%></li>
  <li><%= f.file_field :photo3%></li>
  <li><%= f.file_field :photo4%></li>
  <li><%= f.file_field :photo5%></li>
  <li><%= f.file_field :photo6%></li>
</ul>
  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </p>

  <p>
    <%= f.submit "Update" %>
  </p>
<% end %>

<%= link_to 'Show', @advert %> |
<%= link_to 'Back', adverts_path %>
This topic is locked and can not be replied to.