Rails 3 nested forms with has_many :through, entry in join table dosen't get deleted after update

Posted by Hadi S. on Stack Overflow See other posts from Stack Overflow or by Hadi S.
Published on 2010-10-19T14:37:46Z Indexed on 2010/12/26 15:53 UTC
Read the original article Hit count: 293

Hi,

i have a 'User' model which has a has_many relationship to a 'Number' model through a join table 'user_number' model. I use

accepts_nested_attributes_for :numbers, :allow_destroy => true

in the 'User' model. Everything works fine except that whenever i delete a number from a user in the edit form, the associated number is deleted correctly in the 'number' table, but not the entry in the 'user_number' join table.

In the update controller action i only use this: ... if @user.update_attributes(params[:user]) ...

How can i force rails to also delete the associated entry in the join table?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about delete