PGError: ERROR: column "id" does not exist

40 views
Skip to first unread message

Erwin

unread,
May 21, 2009, 2:30:24 PM5/21/09
to Rails Authorization Plugin
It seems I have the same kind of problem when trying to delete a
record

beside the standard roles / roles_users created by the plugin, I have
the following Model structures :

class User < ActiveRecord::Base
acts_as_authorized_user

has_many :memberships, :class_name => 'Member'
has_many :hubs, :through => :memberships, :include => :org

has_many :roles_users, :dependent => :delete_all
has_many :roles, :through => :roles_users
..

class Hub < ActiveRecord::Base
acts_as_authorizable

has_many :members, :dependent => :delete_all
has_many :users, :through => :members
...

when trying to destroy a previously created hub, I get the following
error :
Mysql::Error: Unknown column 'id' in 'where clause': DELETE FROM
`roles_users` WHERE (`id` IN (NULL))
...
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
associations/association_proxy.rb:219:in `method_missing'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
associations/association_collection.rb:364:in `method_missing'
/Users/yves/Developpement/Projects/webdufour/events/vendor/plugins/
rails-authorization-plugin/lib/publishare/object_roles_table.rb:192:in
`remove_user_roles'

obviously, the roles_users table has only user_id and role_id
keys....

erwin

Erwin

unread,
May 22, 2009, 4:10:12 AM5/22/09
to Rails Authorization Plugin
As per Ian answer to another post :

QUOTED
I managed to solve this by specifiying user_id and role_id as primary
keys for the RolesUser controller since there is no id column for the
roles_user table.
First, you need to install the compositekeys gem (http://
compositekeys.rubyforge.org/). After that, add this to roles_user.rb:
set_primary_keys :user_id, :role_id

Then it should be working.
END QUOTE

Yes , it's working.. is it a bug in the plugin ? why isn't already
included in the core dev ?
Reply all
Reply to author
Forward
0 new messages