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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A845215b22307ff29fb030f340b8a09d?d=identicon&s=25 Gilles T. (bluespot)
on 2006-05-08 21:25
Hello,

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
  end

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.