@article.article_groups.delete_if... Dosn't work!

If I try:

  @article.article_groups.delete_if {|x|
    x.group_id == x.group_id
  }

It does nothing.

If I try:

  articletmp.article_groups.each{ |x|
          @article.article_groups.delete(y)

}

It deletes some of the groups.

@article.article_groups.clear
works.

Why dosn’t the to first examples work as expected??

Do I have to put groups I don’t want to be deleted inn as hidden
fields in my form? (I of course dosn’t want every groups to be deleted
as in the example above).

  • Henrik