active_storage_validations icon indicating copy to clipboard operation
active_storage_validations copied to clipboard

Unknown validator: 'ContentTypeValidator' error

Open SamihaFansur opened this issue 2 years ago • 1 comments

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'}

SamihaFansur avatar Mar 25 '22 08:03 SamihaFansur

Try adding to your .gemspec file: spec.add_dependency "active_storage_validations"

Then: require "active_storage_validations"

MateoLa avatar Oct 06 '22 04:10 MateoLa

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?

Mth0158 avatar Nov 21 '23 11:11 Mth0158

My issue was just user error - gem wasn't added to the right group :)

@isabel-anastasiadis-boost alright, issue solved then :) thank you!

Mth0158 avatar Nov 21 '23 19:11 Mth0158