Comments (15)
I had this same issue. The gem now expects that the json returned is in an array of files. Old code:
format.json { render json: results.to_json }
New code that works:
format.json { render json: { files: results}.to_json }
from jquery-fileupload-rails.
Indeed, my index.js.jbuilder looks like:
json.files @photos do |photo| <----- this line is json.array!(@photos) do |json, photo| in the example
json.name photo.image_file_name
json.size photo.image_file_size
json.url photo.image_url
json.thumbnail_url photo.image_url
json.thumbnail_url photo.image_url(:thumbnail)
json.delete_url album_photo_url(@Album, photo)
json.delete_type "DELETE"
end
took a whole freaking day to figure out :/
from jquery-fileupload-rails.
@raydog153 I dont get it. Where I will put format.json { render json: { files: results}.to_json }. I know it was supposed to be in the controller, but doesnt the gem call the create action once for each photo? And even worst in my case I'm trying to load the results on the products form so that I can associate the photos w/ the product I'm creating. This way I can't use index like @quazimodo have done since it would bring all of them to my form, or not?
Is this issue anyhow related w/ this one tors/jquery-fileupload-rails-paperclip-example#13 ?
UPDATED: I don't think so. Since in the sample I changed the line
{ render json: {files: @Upload}.to_json, status: :created, location: @Upload }
And its still rising
Uncaught TypeError: Cannot call method '_adjustMaxNumberOfFiles' of undefined
Thanks
from jquery-fileupload-rails.
So I was commenting to adejoux that after I upgraded to 0.4.1 my code was not working, and the fix was to change my json response as I stated above. Your json response looks correct, after I did that everything worked. I did not change the gem in anyway, I had to change MY code. As for the calling, I think it depends on your settings, as I have singleFileUploads and sequentialUploads both set to false. I can upload multiple images and my controller code only gets called once and I send the result of all the files back in one json response. Is this clearer?
from jquery-fileupload-rails.
@raydog153 Hello! Thanks for your answer. I'm finding this jquery plugin really challenging but you're right the gem is perfect. It turned out that all I had to do to get the paperclip example working and get rid of that error was changing this line
format.json { render json: [@upload.to_jq_upload].to_json, status: :created, location: @Upload }
to:
format.json { render json: {files: [@upload.to_jq_upload]}, status: :created, location: @Upload }
And I made the same thing on my app.
Things are getting clearer but in a very painful way, but my fault, I'm new with js and jquery.
from jquery-fileupload-rails.
Hi, same problem for me :(
0.4.0 can work , and 0.4.1 or master can not work, I think you made some errors with jquery-file-upload version.
from jquery-fileupload-rails.
I think need to change
var fu = $('#fileupload').data('fileupload')
to
var fu = $('#fileupload').data('blueimpFileupload')
from jquery-fileupload-rails.
Just to be clear, here are the changes which made 0.4.1 work for me..
In uploads_controller create action:
format.json { render json: {files: [@upload.to_jq_upload]}, status: :created, location: @upload }
In your js:
var fu = $('#fileupload').data('blueimpFileupload');
from jquery-fileupload-rails.
Works also with current example code (http://blueimp.github.com/jQuery-File-Upload/):
$('#fileupload').addClass('fileupload-processing');
$.ajax({
url: $('#fileupload').attr('action'),
dataType: 'json',
context: $('#fileupload')[0]
}).done(function (result) {
$(this)
.removeClass('fileupload-processing')
.fileupload('option', 'done')
.call(this, null, {result: result});
});
But I also had to update the index action:
format.json { render :json => { :files => @videos.map{|upload| upload.to_jq_upload }} }
EDIT: and the post action :)
format.json { render json: { :files => [@video.to_jq_upload]}, status: :created, location: @video }
from jquery-fileupload-rails.
Using:
rails 3.2.13
jquery-fileupload--rails 0.4.0 and 0.4.1
I can confirm that changing:
var fu = $(control_id).data('fileupload'),
to:
```javascript
var fu = $(control_id).data('blueimpFileupload'),
Fixes empty file list...for me anyway. I changed nothing else just that one line of javascript.
from jquery-fileupload-rails.
error while uploading any file in create method of controller
NoMethodError in UploadsController#create
undefined method `upload_path' for #Upload:0x9c498c0
please help me
from jquery-fileupload-rails.
The example app is working with 0.4.1 gem .
@tors This ticket can be closed
from jquery-fileupload-rails.
I am facing this issue.
I cloned @digitalfrost 's PR and upgraded to rails 4.2.4 and jquery-fileupload-rails 0.4.5.
from jquery-fileupload-rails.
I am also facing that same issue anyone give some ideas to solve that
from jquery-fileupload-rails.
Guys, check the dates. This issue was opened and answered in 2013, Rails 4 didn't even exist then! I think you're on your own...
from jquery-fileupload-rails.
Related Issues (20)
- sassc dependency break installation on old servers HOT 1
- fileupload() is not function HOT 4
- multipart to allow uploads past 5gb size
- How to get this gem working with Rails 6.
- Release gem v.0.4.4 HOT 3
- Release gem v0.4.5 HOT 1
- jquery fileupload with nested attributes HOT 4
- Can we update the assets for this? HOT 2
- Cant integrate S3 with javascript file upload using presigned post HOT 5
- Use controller or helper instead of model for upload HOT 5
- preview image/video not working HOT 1
- Release gem v0.4.6 HOT 1
- A couple of the asset files seem to be mutually exclusive
- Reuse File Input for a second upload HOT 5
- Widget not working in Rails 5? HOT 1
- Can't direct upload to DreamObjects (S3 compatible OpenStack installation) HOT 3
- Select a file button not responding on production HOT 1
- replace sass with sassc
- Update to support Rails 5.2 HOT 2
- ActionView::Template::Error: Invalid CSS after "screen": expected media query list, was "\" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-fileupload-rails.