Forum: Ruby on Rails destroy failure with has_many associative table without id

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.
Abeb08d874c1357ed69789472698dd9a?d=identicon&s=25 Gilles Tschopp (bluespot)
on 2006-05-08 21:25

I'm newbie in RoR development and I'm coping with the following problem

I have two tables "users" and "appmodules", and I've created an
associative table named "permissions" :

  create_table "permissions", :id => false, :force => true do |t|
    t.column "user_id", :integer, :default => 0, :null => false
    t.column "appmodule_id", :integer, :default => 0, :null => false

I've explicited disabled the id creation (:id => false), as "user_id"
and "appmodule_id" are de facto primary keys. the "has_many" is used for
relationship between user, permission and appmodule.

The problem arises when I want to destroy a user record which has , with
the following error message :

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

Any ideas in order to adjust this DELETE statement ? And many thanks in
advance for the poor newbie like me !
This topic is locked and can not be replied to.