Ruby on Rails Wednesday, November 26, 2014

Hello Christopher,


I trust you are well.

I am not a programmer and need help uploading and hosting a website on Heroku. The site was developed using Ruby on Rails and in my part of the world, a good programmer in this field is hard to come by.

Can you help and what are the steps to do so.

Many thanks.

Tony

On Thursday, November 13, 2014 9:02:17 PM UTC, Christopher Tauer wrote:

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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/15b0e5db-4685-45f7-986d-a538781c9ca6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment