thanks Franco, .. I was hitching my head and just discover in the
log :

WARNING: Can't mass-assign these protected attributes: account

so this attribute was wrong...  and you gave me the answer  !!

On 1 juil, 18:56, Franco Catena <francocat...@gmail.com> wrote:
> 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 <yves_duf...@mac.com> 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 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