Need Help! :)
Use Case: Admin can create another admin when he have role of "SuperAdmin", Admin Can also Create "Agents"
Roles for Admin Model:
- SuperAdmin
- Admin
Admin can create both the roles can create "Agents"
Agent can create "User" but he will not be able to create "Agents" and he should not see users created by other Agents. He has only one Role - "Agent"
Now the problem is : how to initialize "admin", "agent" & "user" in Ability as they are are 3 different models ?
class Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
can :read, Photo, Photo.unowned do |photo|
photo.groups.empty?
end
end
end
Note: Users are under Agent and Agents are under Admin.. I need them to be different models