toptal / database_validations

Database validations for ActiveRecord
MIT License
539 stars 13 forks source link

db_belongs_to with optional: true #40

Closed tarboy closed 5 years ago

tarboy commented 5 years ago

db_belongs_to :company, optional: true gives a validation error: ActiveRecord::RecordInvalid: Validation failed: Company must exist on empty value (company_id=nil), although belongs_to :company, optional: true in the same situation does not give an error

djezzzl commented 5 years ago

Hi @tarboy, unfortunately, optional: true is not supported for db_belongs_to. Besides, it will be supported soon.