I have a form for @profile (controller = profile#new). Inside this form are nested fields for generating an @user (I'm using Devise for user authentification).
If a profile were to be generated without a user this causes lots of issues in the system so I want to set up a validation ensuring that a profile cannot be created without a user. The problem is that there is no pre-exising user to validate for a user_id and also no such id will be generated by the form.
I tried validates_associated :user but it seems to do nothing (i tested it by removing the nested user fields from the form -- the profile still went through successfully).
So has anyone any ideas on how to validate that the user is given alongside the profile (and vice versa -- that a profile is given alongside a user).
Bonus points if anyone can figure out how to test the same.