-1
It is possible to validate the field of another table that is related in a specific model?
For example, I need to validate an email field in a table Requests, but only emails from anyone who is an internal user (which is in a table Users). That is, who is an internal user must enter your email. This information comes from login (Sign-in), that is, from another table (orders belongs_to
user).
In that, in the model requests, I am creating a validation def like this:
def valida_email_interno
errors.add(:email, "Digite o email") if email.blank? and ...# a condição que o usuario é interno, por exemplo, @pedido.user.localpedido == 1
Any idea?