The account data must be in :user => {:account_attributes => {...}} if
you want auto save it.

You can read about it in the documentation of
ActiveRecord::NestedAttributes::ClassMethods (see fields_for in
ActionView::Helpers::FormHelper too).

Regards.

Franco Catena.

On Jul 1, 1:22 pm, Erwin <[email protected]> wrote:
> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to