dependent => destroy without primary key?

Hi-

Can this be done? When I destroy the master, I get an SQL error:

ActiveRecord::StatementInvalid (Mysql::Error: Unknown column 'id' in 'where clause': DELETE FROM `votes`             WHERE `id` = NULL ):

This is because I have no 'ID' in this table.

So, how, in general do you automatically remove join records if there is no id in the join table?

Thanks, Dino

if it can't find them to destroy them, then how does a normal find work if you want to show them. anyway, you can define those sql-fragments with the associations:

:finder_sql - overwrite the default generated SQL statement used to fetch the association with a manual statement :delete_sql - overwrite the default generated SQL statement used to remove links between the associated classes with a manual statement :insert_sql - overwrite the default generated SQL statement used to add links between the associated classes with a manual statement

(not all of them exist for all association types)

if that's not possible you can execute pure sql. but that should be only necessary, if you're forced to use some external db.

dino d. wrote:

This is because I have no 'ID' in this table.

So, how, in general do you automatically remove join records if there is no id in the join table?

look at has_many whatevers :dependent => :destroy within the rails api

hth

ilan