While going through the (quite good) ShareBox Tutorial that teaches you to build a Dropbox-like sharing app, I stumbled on a nasty bug. The tutorial wisely uses the paperclip gem for file attachments, but after moving from local hosting to Amazon’s S3, I started getting an exception in the AssetsController create action.
ActiveRecord::UnknownAttributeError in AssetsController#create unknown attribute: uploaded_file app/controllers/assets_controller:17:in `create'
At the time, Googling the error didn’t help (gasp!), so here are all the pieces together to help any wary travelers who may stumble here looking for the same answer. Turns out, the error doesn’t indicate the real problem at all. Fortunately, however, the fix is simple.
- In the asset model file, asset.rb, change the path to
:s3_credentialsfrom usingRAILS_ROOTtoRails.root. - In the Gemfile, replace
'aws-s3'with'awk-sdk'. Don’t forget tobundle install
That’s all!
Credits go to
- Sikachu for pointing out the Rails_ROOT problem in this issue
- Paperclip‘s rubydocs for S3 Storage for the new dependency tip



One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion