I have this validation
validates :contact_id, :presence => true, :uniqueness => {:message => 'has an account already.'}
in the application.rb model
All is good but I need to only do this validation if the state is “invalid”
For example in the applications table there is a field called state and if there is a application with a contact_id of a user and the state is “invalid” then this validation should not take effect and should let the user save the application
I believe this should do it:
you could also inline that to:
Hope this helps.
If you are going to do it when the state is
notinvalid, then you could do that two ways:Or you could change it a bit more and have a valid message, which I might prefer: