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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:58:40+00:00 2026-06-14T18:58:40+00:00

I’m implementing async photo uploads using backbone & the rails ‘paperclip’ gem: Questions: Do

  • 0

I’m implementing async photo uploads using backbone & the rails ‘paperclip’ gem:

Questions:

  1. Do I need to use jQuery upload (or equivalent lib)?
  2. If so, do I simply override photocollection.sync to call the library?

Item.rb

class Item < ActiveRecord::Base
   has_many: photos
   ...

Photo.rb

class Photo < ActiveRecord::Base

  attr_accessible :photo
  belongs_to :item

  has_attached_file :photo
...

ItemView.js.coffee

class MySite.Views.Items.Edit extends Backbone.View

  template: JST['items/edit']

  initialize: ->
    @modelBinder = new Backbone.ModelBinder
    @model.on('change', @render(), this)

  events: ->
    'submit #edit_item_form' : 'save_item'

  render: ->
    $(@el).html @template( item: @model )

    @new_photo = @model.new_photo()

    @modelBinder.bind @model, $("#item_fields")
    @modelBinder.bind @new_photo, $("#photo_fields")
    @

  save_item: (e) ->
    e.preventDefault()
    @model.save()
    @new_photo.save()

Edit.jst.eco

<form id="edit_item_form" accept-charset="UTF-8" data-remote="true" enctype="multipart/form-data">
<div id="item_fields"> .... </div>
<div id="photo_fields">
   <input type="file" id="upload_photo" name="photo[photo]" />
</div>
...

Suggestions for overall design improvement are welcome

  • 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-14T18:58:41+00:00Added an answer on June 14, 2026 at 6:58 pm

    I ended up opting for the simplicity & cross-browser support of the iframe upload. Implementation is actually pretty trivial:

    MyView.js.coffee:

      events: ->
        'change #upload_photos' : 'upload_photo'
    
      upload_photo: (e) ->
        upload_frame = $('#add_photo_form')
        upload_frame.prop 'target', 'upload_frame'
        upload_frame.submit()
    

    MyTemplate.jst.eco:

    <form id="add_photo_form" method="POST" action="/api/v1/photos" enctype="multipart/form-data">
      <div id="photo_fields">
          <input type="file" id="upload_photos" name="photo[photo]" multiple>
          <input type="hidden" name="authenticity_token" value="<%= $("meta[name='csrf-token']").attr("content") %>">
      </div>
    </form>
    <iframe id='upload_frame' name='upload_frame' src=''></iframe>
    

    Note the addition of the CSRF Token. Without it, the request will fail & have your session cleared.

    • 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
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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.
I have thousands of HTML files to process using Groovy/Java and I need to
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.