# ActiveRecord :dependent problem

**URL:** <https://www.ruby-forum.com/t/activerecord-dependent-problem/90048>\
**Category:** Rails\
**Created:** [March 25, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/activerecord-dependent-problem/90048 "2007-03-25T18:21:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b2d939/32.png) [@christian](https://www.ruby-forum.com/u/christian)\
**Post date:** [March 25, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/activerecord-dependent-problem/90048/1 "2007-03-25T18:21:41Z")

</div>

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 🙂
