Hello all,

I followed the Heroku article on creating a Direct to S3 file uploader for 
my Rails app. 
https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails

I think that I did everything the tutorial said...

In my users_controller, under *new* is:
@s3_direct_post = S3_BUCKET.presigned_post(key: 
"uploads/#{SecureRandom.uuid}/${filename}", success_action_status: 201, 
acl: :public_read)

This code seems fine, and is pretty much exactly as the article says. 

The problem is in my *image_loader.js.erb*, the following:

fileInput.fileupload({
      fileInput:       fileInput,
      url:             '<%= @s3_direct_post.url %>',
      type:            'POST',
      autoUpload:       true,
      formData:         <%= @s3_direct_post.fields.to_json.html_safe %>,


Turns out:

undefined method `url' for nil:NilClass

in fact this breaks an otherwise working app. 

The code in my controller should create the @*s3_direct_post* object, but 
it seems that my javascript doesn't pick it up, maybe? 

I've tried putting the code in the view with <script> tags, as well, with 
the same results.  Any help out there?

Thanks!


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a6a240b6-fad6-4249-8a84-a9af2baf7fe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to