I am using a nested form  ( User has_one Account  .. to hold profile
data)  to UPDATE my user/account data

User model
 has_one :account
 accepts_nested_attributes_for :account, :allow_destroy => true

Account model
belongs_to :user

-------
my form seems to work fine,  I can see in the console, the @user
attributes and  the account attribute in the hash
.... "password"=>"", account"=>{"city"=>"", "zip"=>"",
"country"=>"BE", "street_address"=>"", ...}...

when I debug in the console,
@user.attributes = params[:user]
@user.valid? => true       # OK no errors
@user.attributes = params[:account]
@account.valid? => false  # OK , name is blank...

but if I debug my :edit action,
 if @user.update_attributes(params[:user])
I get true.....  which seems to mean that the account errors are not
tracked ? according to the doc it should be false ...

where am I wrong ?

additional Question :  when errors , how should I display the them
when they are related to the user.account
should I use  @user and @account and :
 error_message_on @account, :first_name,

or only @user and
 error_message_on @user.account, :first_name,

thanks for your recommandations

erwin
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to