rails 3, trying to confirm that an email address is in the dbm, but getting a wrong number of args error

StackOverflow https://stackoverflow.com/questions/8596376

Вопрос

My source is at: https://gist.github.com/f01685376a02a577a9cb

the method in question:

def is_valid_email?(address)
  User.find_by_email(address)
end

I think the solution is to change the value for User.find_by_email(address) to something like User.find_by_email(next_approver_email) = (address) but I know that doesn't work.

Next_approver_email is what we are tying to check against the user.email db column

any ideas?

Это было полезно?

Решение

You need to pass the email into is_valid_email? at the end of line 5

def validate_each(approval, attribute, value)
   approval.errors[attribute] << "must be a valid e-mail address in our system" unless is_valid_email?(value)
end
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top