I have a doubt about the Rolify Gem for Ruby on Rails.
I want to create permissions for especified Organizations, for example,
I have the Admin Permission for Organization 1 (Organization.find(1))
I have the User Permission for Organization 2 (Organization.find(2))
I have the Moderator Permission for Organization 3 (Organization.find(3))
The Organizatios are separated by Client, and I could have many different permissions in many different Organizations.
I tryied to use the in the log "user.add_role "full_admin", Organization.find(1)" for example, and it not have the functionality that I hope. In the DB this query of Rolify armazened is the follow,
2.1.5 :111 > user.add_role "full_admin", Organization.find(1)
Organization Load (1.1ms) SELECT `organizations`.* FROM `organizations` WHERE `organizations`.`id` = 1 LIMIT 1
Role Load (1.2ms) SELECT `roles`.* FROM `roles` WHERE `roles`.`name` = 'full_admin' AND `roles`.`resource_type` = 'Organization' AND `roles`.`resource_id` = 1 LIMIT 1
Role Exists (1.0ms) SELECT 1 AS one FROM `roles` INNER JOIN `users_roles` ON `roles`.`id` = `users_roles`.`role_id` WHERE `users_roles`.`user_id` = 1 AND `roles`.`id` = 7 LIMIT 1
=> #<Role id: 7, name: "full_admin", resource_id: 1, resource_type: "Organization", created_at: "2017-01-06 19:58:31", updated_at: "2017-01-06 19:58:31">
I would be very grateful if anyone could help me, thank you!
Aucun commentaire:
Enregistrer un commentaire