ActiveRecord :dependent problem

Christian Weyer
Sun, 25 Mar 2007 16:21:41 -0000

Hey guys,

I have trouble with the ActiveRecord dependent option, I guess it''s a
bug in ActiveRecord.

I have a superclass called ''list'' which has to subclasses
''hard_list''
and ''intelligent_list''. I''m working with single table
inheritance and it
works well. There is a table called lists, which holds information about
my lists, a table called items, which has all the list items and a table
called lists_items, which knows what item belogs to what list.

Now the problem: my intelligent_list does not have items in that
lists_item table since its items are fetched with an user-defined SQL
query. I used :finder_sql for that and it works fine. But when I want to
delete that list, ActiveRecord tries to nullify the corresponding
entries in my lists_items table. Because I have that intelligent list,
there are no items stored, but that query would not be a problem, it
would just do nothing but it doesnt work. Rails tries to find the items
in lists_items by the field intelligent_list_id since the has_many
definition is in the intelligent_list class. This behavoir is wrong
because the key is called list_id (I''m using single table inheritance),
so how can I avoid that query? How can I tell active record not to do
anything with items in that lists_items table? Or are there other
solutions?

The only thing I see right now to avoid that SQL error is adding an
intelligent_list_id column, but that kinda sucks :)

--
Posted via http://www.ruby-forum.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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---