Giter Site home page Giter Site logo

Comments (15)

raydog153 avatar raydog153 commented on June 17, 2024

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.

siassaj avatar siassaj commented on June 17, 2024

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.

Rogerio avatar Rogerio commented on June 17, 2024

@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

Screen Shot 2013-03-01 at 07 40 27

Thanks

from jquery-fileupload-rails.

raydog153 avatar raydog153 commented on June 17, 2024

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.

Rogerio avatar Rogerio commented on June 17, 2024

@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.

sharp avatar sharp commented on June 17, 2024

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.

sharp avatar sharp commented on June 17, 2024

I think need to change
var fu = $('#fileupload').data('fileupload')
to
var fu = $('#fileupload').data('blueimpFileupload')

from jquery-fileupload-rails.

sarink avatar sarink commented on June 17, 2024

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.

klausistblau avatar klausistblau commented on June 17, 2024

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.

jkloian avatar jkloian commented on June 17, 2024

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.

deepu090 avatar deepu090 commented on June 17, 2024

error while uploading any file in create method of controller
untitled

NoMethodError in UploadsController#create

undefined method `upload_path' for #Upload:0x9c498c0

please help me

from jquery-fileupload-rails.

digitalfrost avatar digitalfrost commented on June 17, 2024

The example app is working with 0.4.1 gem .
@tors This ticket can be closed

from jquery-fileupload-rails.

amitpatelx avatar amitpatelx commented on June 17, 2024

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.

Praveen-Invoscape avatar Praveen-Invoscape commented on June 17, 2024

I am also facing that same issue anyone give some ideas to solve that

from jquery-fileupload-rails.

sarink avatar sarink commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.