Gilles Tschopp
2006-May-08 19:25 UTC
[Rails] destroy failure with has_many associative table without id
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 !
--
Posted via http://www.ruby-forum.com/.
