سؤال

I'm using ruby (2.0.0), rails (3.2.17), cloudinary (1.0.70), and jquery-rails (3.1.0). I'm getting this error only when the image upload tag is nested multiple levels deep. If it's only one level deep, I'm able to upload properly. The file upload that is generated is (cloudname, signature, and api key replaced with "xxxx" for StackOverflow):

<input 
  type="file" 
  name="file" 
  data-url="https://api.cloudinary.com/v1_1/xxxxxxxxx/auto/upload" 
  data-form-data="{&quot;timestamp&quot;:1399504570,&quot;callback&quot;:&quot;http://localhost:8080/cloudinary_cors.html&quot;,&quot;signature&quot;:&quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;,&quot;api_key&quot;:&quot;xxxxxxxxxxxxxxx&quot;}" 
  data-cloudinary-field="page[figures_attributes][1399504574259][images_attributes][0][asset]"
  class="cloudinary-fileupload
">

Which, from what I have read seems to be correct, however I am still getting {"error":{"message":"Invalid cloud_name undefined"}} when I try a direct upload.

EDIT: The URL that it hits when attempting to upload is https://api.cloudinary.com/v1_1/undefined/upload. This makes me wonder why the URL from the data-url attribute in the input is not being used and how this URL is generated.

I'm generating the file upload tag like this:

= f.cl_image_upload :asset

My application.js looks like this:

// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require ckeditor/init
//= require cloudinary
//= require_tree ../../../vendor/assets/javascripts/.
//= require_tree .

Please let me know if you need any other information. Thanks!

هل كانت مفيدة؟

المحلول

The problem was that I wasn't including the cloudinary_js_config script anywhere. So I just added it to the top of the form like so:

= form_for @page, :html => { :multipart => true } do |f|
  = cloudinary_js_config
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top