I have a nested object that is a type of User (say Sub). I had assumed when saving Sub the User validations would be run as well, but apparently not? How would I run all validations in User when creating Sub?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The validations do run from the inherited model.
Here’s a test case showing that it works.
Test case migration:
Test Models:
Tests Cases:
Creating a sub without either a name or email, save should fail with name,email can’t be blank
Creating a sub with no email, save should fail with email can’t be blank.
Creating a sub with no name, save should fail with name can’t be blank.
Creating a sub with name and email, save should succeed.