Been googling and coming up short on finding examples on the best
practice for validating nested forms. I'm still a newb so any concrete
code examples would be great.
My application is going to allow one to record hockey matches between
a home and an away player.
I have a "Match" model which holds some basic match details (date,
period length, etc.)
Each "Match" also contains a collection (two) "PlayerGame" model
objects. Each of these objects holds the statistics of that person's
game (ie score, goals, faceoffs won, etc.) Each has a 'match_id' tying
it to the Match model.
The UI should let you perform on CRUD on a match while letting you
enter the game details for the two player game models that make up the
match. This all works fine. It's validating the nested "PlayerGame"
objects where I'm having the trouble.
I'd like to be able set up validations on the "PlayerGame" model and
call them.. even if manually.. .from the Match controller. Using
"validates_associated :player_games" in my Match model 'sort of'
works, but the resulting display messages are all wrong.. you only end
up with a generic message "Player games is invalid" for each invalid
Are there some examples of what I need to do?
Thanks for any help.