0.0
No commit activity in last 3 years
No release in over 3 years
Gem that helps you to organaize your users with roles and manipulate them. Visit HOMEPAGE for more information how to use this gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
>= 0.14
>= 0

Runtime

~> 3.5.2
>= 4.2.0
 Project Readme

DeviseRoles::Gem

Gem Version Build Status Code Climate Test Coverage

Gem that helps you to organaize your users with roles and manipulate them.

And you are on its HOMEPAGE.

This gem is currently in development, so if you find any issues please report.

Installation

Add this line to your application's Gemfile:

gem 'devise_roles'

And then execute:

$ bundle

Also you need to require it in your Application. You can create and initializer and add next line to it, or just write at top of your controllers

require 'devise_roles'

Pre set up

To use this gem features, you should create table Roles and add roles to it.

Generate User model if you haven't yet:

$ rails generate devise User

To set up Roles follow tutorial from official DeviseRoles page here.

And this is all for setting up. Now you can go to learn methods for this gem.

DeviseRoles Usage

Here is a list of available methods.

user_is

Use this to check if user has the role you need. Here is some example how to use it

if DeviseRoles.user_is('admin', current_user)
  # Everything is ok!
end

user_not

Also there is an opposite method. Here is one more example

if DeviseRoles.user_not('admin', current_user)
  # User is NOT **admin** !!!
end

add_role_to_user

If you want quickly add specific role to user, like in the example

DeviseRoles.add_role_to_user(Role.where(:name => 'banned')[0], current_user)

License

The gem is available as open source under the terms of the MIT License.