carrierwave_direct icon indicating copy to clipboard operation
carrierwave_direct copied to clipboard

Unclear how to turn off validations

Open lawso017 opened this issue 8 years ago • 2 comments

In trying to get my existing app to run with master in prep for a new release, the new ActiveRecord validations are causing problems.

First, I do not think it's desirable to add new validations that are turned on by default. Validations in Rails don't work that way -- they're there if you need them, but they're not activated by default.

Second, I can't figure out how actually turn off the validations that are turned "on" by default (Unique Filename and Filename Format). I've tried:

    validates :document, unique_filename: false
    validates :document, filename_format: false

It looks like the validations can only be deactivated in the global Carrierwave config block. But at the moment I've not figured out how to make that work either.

Anyway, not sure we should push out a new release with these defaulting to on. Will likely cause grief for many.

lawso017 avatar Jun 07 '16 02:06 lawso017

What are the validation error you are getting? The only validation changes are from ac432977877e22de7db368936d922e81207bf99a I agree we should not have breaking changes with a new release.

p8 avatar Jun 07 '16 18:06 p8

@p8 my unit tests were failing due to the filename_format and unique_filename validations, which as you noted are new since 0.0.15.

It took me a while to figure out where the failures were coming from; while I could work around them by adjusting my config to turn off the validations, it was an unwelcome surprise.

I'm not totally clear on the use case behind the validations; the syntax presented in the documentation makes them seem like ActiveRecord-type validations (that's how they're implemented), but the fact that several of them default to "true" (i.e. on) is inconsistent with AR validations in general. I.e., you can't actually turn them off within the model, you have to turn them off globally first in your config file.

I really think the validations should all default to false because they are new and haven't been previously enabled for existing users.

lawso017 avatar Jun 07 '16 21:06 lawso017