I'm working on a simple project using Paperclip to upload images. Everything has been working just fine until I attempted to integrate S3 with Paperclip. Upon 'uploading' a user's image I get a NoMethodError (undefined method 'match' for nil:NilClass):
error. This only happens when I have my S3 configuration running - if I comment it out the file uploads perfectly.
My configuration:
development.rb:
....
....
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['AWS_BUCKET_ID'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
My Model:
class User < ActiveRecord::Base
has_attached_file :image_file, default_url: "/myapp/images/:style/missing.png"
validates_attachment_file_name :image_file, matches: [/png\Z/, /jpeg\Z/, /tiff\Z/, /bmp\Z/, /jpg\Z/]
entire error output from console:
NoMethodError (undefined method `match' for nil:NilClass):
app/controllers/images_controller.rb:33:in `block in create'
app/controllers/images_controller.rb:32:in `create'
Things I tried:
I added the AWS keys and bucket name directly into the code instead of as an environmental variable.
As mentioned above, I commented out the AWS configuration in my environment file and it seemed to work perfectly.
It's probably worth mentioning that I installed the fog
gem earlier to start configuring for Google Cloud Storage, but decided to stick with S3 instead. I used gem uninstall fog
to remove the gem but it appears some dependencies stayed behind.