Forum: Ruby on Rails Unable to Clear a :through Relationship w/ clear or replace

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 Hunter Hillegas (Guest)
on 2007-03-07 05:34
(Received via mailing list)
I have the following setup:

class NewsItem < ActiveRecord::Base
   has_many :connections, :as => :connectable, :dependent => :destroy
   has_many :ideas, :through => :connections

The relationship is a has_many :through that is also polymorphic.

I can add ideas to news items with this code:


related_ideas is an array of ideas.

The problem comes when I try to update the ideas for an existing news

First I tried this:


This literally does nothing - no log output at all, no DB activity.

Then I tried this:


Again, nothing at all. No error, nada. I would have expected the
'clear' method call to remove the records that associate the news
items and the ideas.

What am I doing wrong?

This topic is locked and can not be replied to.