Association Methods Not Working - No SQL!

Hey All,

I have some associations that seem to be messed up as their methods
(i.e. clear, delete) don’t do anything - no errors, no SQL, nothing!

It’s a polymorphic has_many :through. Here goes:

class Connection < ActiveRecord::Base
belongs_to :idea
belongs_to :connectable, :polymorphic => :true
end

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

class Idea < ActiveRecord::Base
has_many :connections
has_many :news_items, :through => :connections
end

Let’s say I do this:

news_item.ideas << ideas
=> [#<Idea:0x34e5900 @attributes={“name”=>“Test Idea”,
“short_description”=>“Yodel”, “id”=>“10”, “long_description”=>“Homey”}
, #<Idea:0x34e58b0 @attributes={“name”=>“Hunter’s Other Idea”,
“short_description”=>“I had two ideas.”, “id”=>“12”,
“long_description”=>“Yes, I did.”}>]

news_item.ideas.size
=> 2

Great so far. The records are created, everything works. The problem
is that .replace and .clear both do NOTHING:

news_item.ideas.clear
=> []

Okay, that looks right but there was no SQL generated for that so…

news_item.reload
news_item.ideas.size
=> 2

?!?!?! I’ve tried this a million ways and I can’t figure this out.
Are the relationships specified incorrectly? Like I said, adding
items and viewing them works fine. It’s just anything that requires
the connections between news items and ideas to be deleted that fails

  • but there are never any error messages, just a silent failure w/ no
    SQL generated.

This is on Rails 1.2.3 / Ruby 1.8.5 on OS X Tiger 10.4.9.

Any help would be very, very much appreciated.

Thanks,
Hunter