addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [NYC-rb] Re: Spine and File Uploads

From: Topper B.
Sent on: Monday, October 8, 2012 4:42 PM
Yeah - async file upload is still a huge pain.  Some of the modern browsers make it better, but you'll be falling back to flash for IE me thinks (it's been a while). was what we used (we had large video files and had to chunk).  

On Mon, Oct 8, 2012 at 4:36 PM, Stephen Schor <[address removed]> wrote:
I'm going to reply to myself for posterity...

Spine isn't serializing the file field...I looked at the implementation of fromForm()
and saw it calls the jQuery method serializeArray() to make the Form element into a JSON object.

From serialzeArray()'s Docuemtation:

"No submit button value is serialized since the form was not submitted using a button. 
Data from file select elements is not serialized."

"As someone else mentioned, you can submit a form containing file inputs via ajax, but it requires some hairy iframe magic."

So what's up? - has anyone worked on a JavaScript MVC app that uploaded a file?
Did you end up using something like jQuery FIleUpload.


On Thu, Oct 4, 2012 at 6:22 PM, Stephen Schor <[address removed]> wrote:

I have a Spine app - backed by a Rails 3.1 app - but it seems like my model.fromForm() method is
serializing the appropriate attributes except the for the one fed by file upload....

Let's say the form is to save an instance of Book.
My form looks like

  <form enctype="multipart/form-data">
    <input class="file optional" name="image" type="file">
    <input type="submit" value="Save">

I've defined an image attribute in my Book class like:

class App.Book extends Spine.Model
  @configure 'Book', 'image', ...other attributes

In my ActiveRecord Book class I've made sure that :image is attr_accessible.
Sure enough - if I drop a hidden input in the field, and see that fromForm()will serialize it.
Also - I should say that Book#image is a CarrierWave I type this I just thought 
"Should I be telling spine this is a @belongsTo relationship and create a spine Image model?"

I figured someone on the list has seen this before - if you help me out on this I promise
to get you all the beer you can drink...out of Pivotal's fridge at the next meetup.
It's the least I can do - don't mention it.


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Stephen Schor ([address removed]) from NYC.rb.
To learn more about Stephen Schor, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Topper Bowers

[address removed]

Our Sponsors

  • Pivotal Labs

    Provides the awesome event space we use every month!

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy