Problems using the authorization plugin from Bill Katz

Hello everyone,
I was trying to set up access control in a new application Im working
I’m trying to use the excellent authorization plugin from Bill K.,

Its pretty straight forward to setup and should be to use.
But when i try to give the same permission on two differents users on
the same object i get an error.
(Well , Im kinda new to all this rails stuff)

r = Red.find(1)
u1 = User.find_by_login(“ismael”)
u2 = User.find_by_login(“ismael2”)

u1.has_role “proprio”, r

u2.has_role “proprio”, r

ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry ‘5’ for
key 1: INSERT INTO roles_users (updated_at, role_id, id,
user_id, created_at) VALUES (‘2006-07-11 13:58:35’, 5, 5, 20,
‘2006-07-11 13:58:35’)

I know what the Duplicate key mean, but am I using the plugin
correctly or you cant have 2 users with the same permission on the
same object?

thank you

[email protected] :r&d web
tél: 514.678.6066

This is probably a problem with the migration for roles_users. Make
sure roles_users table doesn’t have an independent ‘id’ field. (This
is done by using :id => false when doing create_table for
roles_users.) The migration example in the comments section was
updated in the subversion repository, and the test apps do the right
thing in the actual migration code. Let me know if this isn’t the

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs