|Sent on:||Friday, October 5, 2012 1:29 AM|
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."
Did you end up using something like jQuery FIleUpload.
Heyo.I have a Spine app - backed by a Rails 3.1 app - but it seems like my model.fromForm() method isserializing 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"></form>I've defined an image attribute in my Book class like:class App.Book extends Spine.Model@configure 'Book', 'image', ...other attributesIn 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 uploader...as 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 promiseto 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.Stephen