Search code examples
ruby-on-railsrolescancanrails-consolerolify

Adding Roles to Rails Composer, Devise, CanCan, Twitter Bootstrap


I am making an app that started with Rails Composer, Devise, CanCan, Twitter Bootstrap.

I know how to set the users permissions using the ability model. How do I add more roles to attribute certain permissions to?


Solution

  • I was unable to find any help during my search, so here is what I came up with on my own.

    Somewhere between rolify and rails composer, a Role table is made.

    1. Enter the rails console

      $ rails c
      
    2. Add your new role

      irb> Role.create name: 'new-role'
      

    *Use this to display all of your roles

        irb> Role.all
    

    *To Delete Roles

        irb> Role.delete(role_id)