I'm not sure but if you look at http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
<http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html>your params does not have the same format as the one stated in the link. It should be "contact_methods_attributes"=>[{"details"=>"test", "id"=>"1", "_destroy"=>"false"}] On Fri, Feb 11, 2011 at 11:28 AM, Tim Uckun <[email protected]> wrote: > On Fri, Feb 11, 2011 at 4:07 PM, Jim Ruther Nill <[email protected]> wrote: > > i don't know if location is a special term or not. But I have a question, > do > > have an attr_accessible line in your user model? > > If you do, check that you have the location attribute listed there. > > DOH!. Yes that was the problem... > > Now for the second part.... > > class User > has_many :contact_methods > accepts_nested_attributes_for :contact_methods, :allow_destroy => true > > end > > The form has this (from above) > > = render 'contact_methods' , {:f => f} > > the partial looks like this. > > = f.fields_for :contact_methods do |c| > %tr > %td > = c.object.icon.nil? ? nil : image_tag(c.icon) # > %td > = c.text_field :details ,:class => "text-input" > %td > - unless c.object.new_record? > = c.hidden_field :_destroy > = link_to 'Delete', '#', :class => 'delete_contact_method' > > > This displays the records fine, submits them as > "contact_methods_attributes"=>{"0"=>{"details"=>"test", "id"=>"1", > "_destroy"=>"false"}} but it won't update them. > > There is no error message and @user.save! does not throw an exception. > > I created the contact method by hand but it won't delete it or update it. > > The ContactMethod has no attr_accessable and I added :contact_methods > to the user attr list > > So why doesn't the nested_atrributes work? > > -- > 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. > > -- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- 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.

