djfobbz
2008-Nov-28 05:15 UTC
How to Validate Child Object Virtual Attribute against Parent Object Field?
Ok, I have the following: Account => has_many => Users Users => belong_to => Account When an Account is created, an ''account_code'' is also generated and stored within the Accounts table. Users must use this ''account_code'' in order to Signup for the service. My problem is how do I compare the User submitted ''account_code'' in the Signup form against the ''account_code'' stored in the parent object Account? Do I define this ''account_code'' as a virtual attribute to the User model? Also, once I make the comparison, in case there is a mismatch, how do I add the error along with all other errors relating to User model? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---