active_storage_validations
active_storage_validations copied to clipboard
Unknown validator: 'ContentTypeValidator' error
I get a Unknown validator: 'ContentTypeValidator' error on rails 6 when I try to validate my pdf files which are attached as a has_many _attached attachment.
validates :files, content_type: {in: 'application/pdf', message: 'Please upload .pdf files only'}
Try adding to your .gemspec file: spec.add_dependency "active_storage_validations"
Then: require "active_storage_validations"
We were getting a similar issue initially and realised we'd put the gem in the :test
group instead of everywhere
@SamihaFansur, @isabel-anastasiadis-boost could you give us a bit more context on this issue so we can investigate it?
My issue was just user error - gem wasn't added to the right group :)
@isabel-anastasiadis-boost alright, issue solved then :) thank you!