Ruby on Rails Paperclip Cloudfront Gotcha
Short story: turn on forward query string in CloudFront configuration
Long story: Had the damnedest time debugging an issue with Paperclip images not updating over the weekend. I’d done a number of updates recently, from Ruby 1.9.3 to Ruby 2.1.1, new version of Paperclip, as well as various feature releases, which served to, err cloud my judgement.
First I looked at our staging app, which runs on the same machine and configuration, and no problem there. Next looked to find out if the record was failing to save, that wasn’t the problem. Looked at user permission errors; imagemagick problems due to Ruby update; etc etc. Finally noted that my app was deleting a file that was different than the filename being referenced in the site. At that point it occurred to me that CloudFront was probably the issue. I dug around in the filesystem a bit, scp’d my files to localhost to take a look at them, found out that the images were being changed correctly. At that point it occurred to me that it was certainly a CloudFront issue.
Couldn’t find much documentation about this, but what ended up fixing the problem was going into our CloudFront configuration and enabling forwarding query strings.
I am available for Ruby on Rails consulting work – get in touch to learn more.