-2

i am following this tutorial http://eveloverails.wordpress.com/2011/04/02/183/. I have created the users through devise and i want when the user log in as an admin he should have the list of users in which it can edit the permissions of the users like edit destroy,etc.

Thanks in advance

Mohd Anas
  • 634
  • 1
  • 9
  • 22

1 Answers1

-1

you can add a field in devise model call role. then create cancan ability class in your model then define your authorization like

class Ability
  include CanCan::Ability

  def initialize(user)
  # Define abilities for the passed in user here. For example:
     user ||= Login.new # guest user (not logged in)
     if user.role == 'admin'
       can :manage, :all
     else
       can :read, :all
     end
  end
end 

See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities