I\'m trying to create a condition in which the attribute \'one\' is zero and the attribute \'two\' is one, then a model is not valid. But when I make:
Model.
I think you have an error in your syntax:
validates :one, :two, :presence => true, :if => :condition_testing?
def condition_testing?
!(one == 0 && two == 1)
end
There was one :if too many in there...
And if I understand correctly you want to have it only validate in case one == 0 && two == 1
?
Then you condition_testing? is inverted (leave out the !())
If unsure you could try to use pry and insert a breakpoint into your condition_testing?
method to see what's going on.
(Please note added ":" before condition testing)