I have a question on rails validates. I need to validate that one field
is
filled out if another field has a certain value. The code is below, but
if
license has extended selected then the extended license type needs to be
filled in. I have this but it isn’t working, when I fill the form out
and
select extended and don’t check anything for extended_license_type, it
validates fine and I get no error message.
validates :license, presence: true
validates :extended_license_type, presence: true, :if =>
:license_extended?
private
def license_extended?
license == ‘extended’
end