Ingo
unread,Aug 11, 2009, 8:57:18 AM8/11/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
I have two models, User and Profile, that have a one-to-one
relationship and which I am creating in the same form. I thought I'd
give nested object forms a go, but got stuck with two problems:
1) When I use the syntax from the tutorials I found,
'form.fields_for :profile do |profile_form|', then the key of the
resulting params hash is 'profile', and the User model seems to expect
'profile_attributes' instead. So I had to change the syntax to
'form.fields_for :profile_attributes do |profile_form|'. Is this the
way to go?
2) What is the best way to get the form fields to be pre-filled with
existing profile attributes when the form comes back with validation
errors? Shouldn't that happen automatically? Maybe the fact that it
isn't is related to 1) somehow?
Thanks for any hint!
ingo