Answer the question
In order to leave comments, you need to log in
How to write a validation so that either 1 field is valid or at least 2?
There are 2 fields comment and file.
You need to check for emptiness (comment or file).
If it were a simple text field, it would be possible to resolve all this with ifs.
But the field file (construction) is generally then transformed into other fields by a peperclip and I don’t know how to check it for emptiness through if.
Is it possible to somehow remove errors in the model, at the validation stage?
Answer the question
In order to leave comments, you need to log in
Or use the before_validation callback to write garbage in the field, and then check and work with the model object as you like before saving.
Although, of course, such crutches speak of not the best thoughtfulness of the model initially.
The essence of the question is not clear, but apparently there are many ways to check the peperclip
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question