Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:41:15+00:00 2026-06-01T18:41:15+00:00

I did the multiple uploads with paperclip based on this app https://github.com/websymphony/Rails3-Paperclip-Uploadify and it’s

  • 0

I did the multiple uploads with paperclip based on this app
https://github.com/websymphony/Rails3-Paperclip-Uploadify and it’s working fine, but now I need to build a form where user can delete some of this uploads.

I have this form for deleting the uploads for one product

<%= form_for @product, :html => { :method => :put }, :html => { :multipart => true } do |f| %>
  <h3 id="photos_count"><%= pluralize(@product.uploads.size, "Photo")%></h3>
  <%= f.fields_for :uploads do |photo_fields| %>
    <% if !photo_fields.object.nil? and  !photo_fields.object.new_record? %>
      <%= image_tag(photo_fields.object.photo.url(:thumb)) %>
      <p><%= photo_fields.check_box :_destroy, :class=>'checkbox' %>  Delete item</p>
    <% end %>
  <% end %>
<% end %>

this form somehow displays the correct uploads number, I can see in the terminal window that all uploads with product_id = product.id are found in the database but I have no image displayed in the page as you can see on the image:

Terminal

Started GET "/admin/products/40" for 127.0.0.1 at Tue Apr 10 10:20:06 +0300 2012
  Processing by Admin::ProductsController#show as HTML
  Parameters: {"id"=>"40"}
Creating scope :page. Overwriting existing method AdminUser.page.
  AdminUser Load (2.4ms)  SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 5 LIMIT 1
Creating scope :page. Overwriting existing method Product.page.
  Product Load (0.5ms)  SELECT `products`.* FROM `products` WHERE `products`.`id` = 40 LIMIT 1
Creating scope :page. Overwriting existing method Upload.page.
  Upload Load (0.4ms)  SELECT `uploads`.* FROM `uploads` WHERE `uploads`.`product_id` = 40 AND (file_avatar = 1) LIMIT 1
Creating scope :page. Overwriting existing method Category.page.
  Category Load (0.4ms)  SELECT `categories`.* FROM `categories` WHERE `categories`.`id` = 2 LIMIT 1
   (0.6ms)  SELECT COUNT(*) FROM `uploads` WHERE `uploads`.`product_id` = 40
Rendered admin/products/_delete_photos.html.erb (154.3ms)
  CACHE (0.0ms)  SELECT COUNT(*) FROM `uploads` WHERE `uploads`.`product_id` = 40

enter image description here

additional info:

upload.rb

class Upload < ActiveRecord::Base
  attr_accessible :product_id, :photo 
  belongs_to :product
  has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }

  attr_accessible :created_at, :photo_file_size, :photo_file_name, :updated_at, :photo_content_type,
                  :file_avatar, :photo_updated_at, :uploads_attributes, :photo_attributes
end

product.rb

class Product < ActiveRecord::Base
  has_many :uploads, :dependent => :destroy
  accepts_nested_attributes_for :uploads, :allow_destroy => true
end

uploads_controller.rb

  # GET /uploads/1/edit
  def edit
    @upload = Upload.find(params[:id])
  end

  # POST /uploads
  # POST /uploads.xml

  # PUT /uploads/1
  # PUT /uploads/1.xml
  def update
    @upload = Upload.find(params[:id])

    respond_to do |format|
      if @upload.update_attributes(params[:upload])
        format.html { redirect_to(@upload, :notice => 'Upload was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @upload.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /uploads/1
  # DELETE /uploads/1.xml
  def destroy
    @upload = Upload.find(params[:id])
    @upload.destroy

    respond_to do |format|
      format.html { redirect_to(products_url) }
      format.xml  { head :ok }
    end
  end

so the problem here is: Why the images are not displayed with the checkboxes next to them. Thank you.

Update

Processing by ProductsController#update as HTML
  Parameters: {"commit"=>"Delete sellected photos", "authenticity_token"=>"af5+YybkZ1KMu/DmZmlui9frqQX5ka8v/vvv0hi9PVo=", "id"=>"42", "product"=>{"uploads_attributes"=>{"7"=>{"id"=>"322", "_destroy"=>"1"}, "6"=>{"id"=>"321", "_destroy"=>"0"}, "5"=>{"id"=>"320", "_destroy"=>"0"}, "4"=>{"id"=>"319", "_destroy"=>"0"}, "3"=>{"id"=>"318", "_destroy"=>"0"}, "2"=>{"id"=>"317", "_destroy"=>"0"}, "1"=>{"id"=>"316", "_destroy"=>"0"}, "0"=>{"id"=>"315", "_destroy"=>"0"}}}, "utf8"=>"✓"}

after Jesse’s reply I have now the images in my page, with checkboxes, but the photos are not deleted after I check some of them and press the submit button

products_controller

def update
@product = Product.find(params[:id])

respond_to do |format|
  if @product.update_attributes(params[:product])
    format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
    format.xml  { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml  { render :xml => @product.errors, :status => :unprocessable_entity }
  end
end

end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:41:17+00:00Added an answer on June 1, 2026 at 6:41 pm

    You are attempting to use nested_attributes, but have not enabled that on the Product model

    class Product < ActiveRecord::Base
      has_many :uploads, dependent: :destroy, autosave: true
      accepts_nested_attributes_for :uploads, allow_destroy: true, reject_if: :all_blank
    end
    

    more: http://apidock.com/rails/ActiveRecord/NestedAttributes/ClassMethods/accepts_nested_attributes_for

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to make multiple files uploading, and did this: rails plugin install git://github.com/kpitn/swfupload.git
I looked at this question: Uploading multiple files with Django but it did not
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
Did some googling and couldn't find a clear answer on this. My assumption is
To update my multiple repos, I did: git bulk fetch origin git bulk pull
I want to write a jQuery file uploading program, using this plug-in http://aquantum-demo.appspot.com/file-upload Despite
I am working on this website that catalogues products with their basic information and
Railscasts did a great tutorial on how to do multiple edit from a selection.
Unable to do multiple overlayed videos using flowplayer with jQuery I did single overlayed
I recently simulated multiple login in PHP using 1 account. Here's what I did

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.