Rails - Relationship BD

Asked

Viewed 41 times

2

I have a table user, where I have a mandatory field cidade, and I have a table contatos (that is belongs_to: user), but the form does not have the field cidade which is mandatory to user. How do I put the city countryside being optional no model contato?

Fez belongs_to > optional: true and it didn’t work.

No models/user.Rb I am making this validation with validate_presence_of

1 answer

1

Try this way:

belongs_to :user, optional: true

Browser other questions tagged

You are not signed in. Login or sign up in order to post.