So I want to do something like this and I’ve been playing around with the syntax and looking around but still no cigar. Is this possible?
validates :description, presence: false unless object.attached_model.description == "Custom"
has_many: :attached_model
http://guides.rubyonrails.org/active_record_validations_callbacks.html#using-a-symbol-with-if-and-unless
I see MrYoshiji also mentioned this already. You can see more examples in the guides. However note that you can’t validate for :presence => false (this does nothing). If you want to validate that it’s blank then you need to write a custom validator.
I am using attached_model (singular) here since that is what you used in your example, if you only have has_many then change it accordingly, like MrYoshiji pointed out.