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

  • SEARCH
  • Home
  • 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 7065577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:58:24+00:00 2026-05-28T04:58:24+00:00

I am uploading multiple images (4 file fields) using paperclip, which is working fine

  • 0

I am uploading multiple images (4 file fields) using paperclip, which is working fine just fine and dandy but I want to also attach a description to 3 of the 4 file fields. So far I have created a model called “Asset” which has the following:

class Asset < ActiveRecord::Base
  belongs_to :project 
  has_attached_file :asset
end

My project model is aware of the assets and has_many assets:

class Project < ActiveRecord::Base
  validates :title, :presence => true

  has_many :assets
  accepts_nested_attributes_for :assets
end

And in my _form.html.haml I am creating 4 fields like so:

- number = 0
= f.fields_for :assets do |asset|
  %ul.fields
    %li= asset.label :asset, "File ##{number += 1 }"
    %li= asset.file_field :asset

And of course my projects_controller.rb contains the following to build the 4 fields:

def new
  @project = Project.new
  4.times { @project.assets.build }
end

My questions are, where is the best place to put this “description” for each of the fields, the assets or projects? My second one is how do I not render a description field for the last one in the loop but do in fact render a description field for the first 3?

  • 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-05-28T04:58:24+00:00Added an answer on May 28, 2026 at 4:58 am
    1. in the Asset model. I’m assuming the description is of the image.
    2. a quick way would be to just put

      ...
      %li= asset.file_field :asset
      - if number < 4  
        %li = asset.label :description  
        %li = asset.text_field :description
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm uploading multiple files via XmlHTTPRequest and HTML5. I have the uploading working fine,
I'm working in tiny project that deal with multiple file uploading. at the begining
I have a form with flask-wtf for uploading images, also file field can be
I see a ton of questions about uploading multiple files, but none about uploading
I have a Flex3 application which has to be capable of uploading multiple files
Uploadify is a jQuery/Flash plugin for uploading multiple files. It's working great, except I
I am using Jquery Uploadify for images upload with PHP, here i have multiple
I am using Jquery Uploadify for images upload with PHP, here i want to
I need to upload images using symfony, but ive not been able to do
So I am using the Uplodify plugin to allow users to upload multiple images

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.