Pier-Hugues Pellerin
2006-Jul-11 20:56 UTC
[Rails] Problems using the authorization plugin from Bill Katz
Hello everyone, I was trying to set up access control in a new application Im working on, I''m trying to use the excellent authorization plugin from Bill Katz, 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 -- -- ph, ph@bacterie.org :r&d web t?l: 514.678.6066
Bill Katz
2006-Jul-11 22:06 UTC
[Rails] Problems using the authorization plugin from Bill Katz
Hi, 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 problem. best, Bill On 7/11/06, Pier-Hugues Pellerin <ph@bacterie.org> wrote:> Hello everyone, > I was trying to set up access control in a new application Im working on, > I''m trying to use the excellent authorization plugin from Bill Katz, > > 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 > > -- > -- > ph, > ph@bacterie.org :r&d web > t?l: 514.678.6066 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >