Dean Fields


290 Experience
2 Lessons Completed
0 Questions Solved


<%= f.attachment_field :photos_images, multiple: true, direct: true, presigned: true, host: '' %>

This is my attachment field currently. I'm going to attempt to try a couple of things out, i.e removing presigned and attempt to see if I can figure out where the issue is, by looking at the differences between mine and yours.

I've also set my to use Cloudfront. I had to set host: '' on the attachment field otherwise the URL when uploading gets messed up:

[cf url] 404 (Not Found)

If I remove // on the front of

the images for attachment_image_tag work, but do not if // is added (have to overwrite the host again)

I'm not sure what is factoring this or if it's connected

Ok so in my view I outputted refile.secret_key and it seems to be set somehow.

I copied and pasted this in to the initializer just to see if it would make a difference. When I took the token out of the url, no luck. I'm not receiving any errors in my logs or anything when I don't set secret_key so it must being set by the system itself?

I made sure I restarted.

Using <%= attachment_image_tag(photo, :image, :fill, 300, 300) %>

Seems to set the token in the url - but I haven't got a secret_key set?

But no errors seem to be occurring?

I can only imagine, it's almost like you need to make micro videos for each thing so that it can be modularly updated when things change :)

Ah right!, ok thank you very much

Thanks Chris,

I will take a second glance, but I don't think it's explained in the instructions


I have followed along with both videos, but have come up with a little issue while attempting to generate a thumbnail within the success event. It seems to be automatically requiring the token which is not required in these videos.

I have not set a secret_key within my initialiser as the documentation suggests. I have discovered you can generate and check a token via these commands:

example url: (/store/fill/400/200/a7d1406d633ce73f124a33598690d146f8fd422dbf66d9f56b6a12eb2d31/image)

I paste these in to the js line for displaying the image:

$(fileupload_id + ' img').attr(
src: "/attachments/[token here]/[url here]"

This now works and shows the image. - of course it's not the one being uploaded, but one I took from s3 from a previous upload

is there a way to generate the token via javascript?

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.