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 3694204
In Process

The Archive Base Latest Questions

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

So, I’m working on an app where users can upload and manage photos with

  • 0

So, I’m working on an app where users can upload and manage photos with a bunch of industry specific metadata attached to them.

The Photo model has all this metadata in it, and I’m using Paperclip to attach the actual image file to the model and store the images on Amazon S3.

The user interaction currently works like this:

  1. A user clicks “Add Photo” and is taken to the “New Photo” page where he is presented a form.
  2. The first thing on the form is a file chooser. The user selects a file.
  3. Beneath this are several different fields of metadata for the user to fill out, so the user fills these out.
  4. The user hits submit, the file uploads and a new Photo object is created, the user is redirected to a different page.

So, the obvious improvement that I’d like to make is for the photo to actually upload at the beginning of this process so that there isn’t such a noticeable delay between hitting submit and being redirected to the next page. It would also be nice to be able to show the user a thumbnail preview of their photo once it’s done uploading, so that they can see the photo they’re putting in metadata about as they fill in the form.

I figure I could make that happen if I split the image file into its own model, but I’d then be referring to the images like so:

@photo.attachment.file.url instead of the simpler @photo.file.url that I use now. I’d rather not “nest it” more deeply than I have to.

Also, splitting it into two models raises the issue of managing orphans, which I currently don’t have to deal with.

So my questions are:

  1. Is there a good way – preferably not using Flash – to create this asynchronous upload behavior without splitting into two models, OR —
  2. If I must split the metadata and the file into two models, is there a way to get Paperclip to treat an attachment as its own model so that I can access it using <modelname>.<paperclip_method> instead of <model_name>.<attachment_attribute>.<paperclip_method>?

I know that’s a big question, so thank you very much in advance for your help!

  • 1 1 Answer
  • 1 View
  • 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-19T04:28:08+00:00Added an answer on May 19, 2026 at 4:28 am

    After a week of experimentation I just thought I’d post what I finally did:

    I did in fact split the photo into two models, because I ended up having to create empty records with any approach I tried. I found it was easier in the end to have two seperate models because:

    1. It made it easier to work within Rails convention (use the standard REST actions for the second model to handle asynchronous updates, rather than having to add several custom actions to the parent model).

    2. No matter which option I tried I ended up having orphan records as a possibility. I found it was easier to have a parent object which does not ever save unless valid (the Photo model in my case), and to have attachments which may be orphans. The attachments are never called directly anywhere in the app, so there’s no risk of accidentally having an empty record being pulled up, and no need to set a default scope or something in order to only show “valid” photos. Cleaning up orphans is pretty easy, just do Attachment.where( :parent_id => nil ) and delete all those.

    3. I can maintain the previous code by simply delegating attachment to photo. See this answer on another question.

    I hope this saves others some trouble down the road. If you need Ajax functionality with attachments it is best to make them their own model. Also, for adding ajax file upload to forms, check out https://github.com/formasfunction/remotipart. This saved my app.

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

Sidebar

Related Questions

I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I am writing an app with both english and french support. The app requests
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.