Using before_create to see if the record exists. Have four variables/columns (alpha, beta, delta, gamma). What to see if the record exists that matches but one or more of the columns is NULL.
My problem: If alpha, beta, and delta are none null, but gamma is null, the exists query will never say the record already exists because the possibilities of gamma are infinite. Is there a way to get around this problem without going through every if statement combination.
Example:
Database record: alpha = 1, beta = 4, delta = NULL, gamma = NULL
New record: alpha = 1, beta = 4, delta = NULL, gamma = NULL <-- this will return does not exist because of null values.
Before Create
!Model.where("alpha = ? AND beta = ?, delta = ?, gamma = ?", self.alpha, self.beta, self.delta, self.gamma).find(:first)
To check nil you have to use
ISinstead of=operatorTry following