Questions tagged [rolify]

Rolify is a very simple Roles library without any authorization enforcement supporting scope on resource object.

Rolify is a very simple Roles library without any authorization enforcement supporting scope on resource object.

See Rolify on GitHub.

229 questions
15
votes
1 answer

Rolify Table Error (user.add_role :admin Unknown Key Error)

I'm attempting to setup the rolify gem and I'm running into an issue assigning a role to a user in the console. Here's my error: 2.2.1 :007 > user.add_role :admin ArgumentError: Unknown key: :optional. I'm running devise with cancancan and rolify.…
John Gerard
  • 299
  • 4
  • 19
12
votes
2 answers

CanCanCan throws a regular Rails error on an exception rather than a flash message like I specified

I am using CanCanCan, Devise & Rolify. My ApplicationController looks like this: class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. …
marcamillion
  • 32,933
  • 55
  • 189
  • 380
12
votes
2 answers

Rolify tables are not getting created

After bundle installing the gem(gem 'rolify'), I have generated the file using the following command, rails g rolify Role User Below files got created, invoke active_record create app/models/role.rb invoke rspec create …
Abhiram
  • 1,459
  • 14
  • 23
10
votes
2 answers

Why is Pundit not coupled with Rolify like CanCanCan is?

I am using Devise and interested in using Pundit but cannot find much on if it should be integrating with Rolify or if it is stand alone. CanCanCan works nicely with Rolify and I like the roles model. Am I missing a major reason why Pundit and…
MicFin
  • 2,431
  • 4
  • 32
  • 59
7
votes
4 answers

Defining Roles with Rolify

I am trying to make an app with Rails 4. I am looking at role management and want to use Rolify because it supports instance level role assignment. For others looking at the same problem, there are 2 really good answers below (I can only tick one…
Mel
  • 2,481
  • 26
  • 113
  • 273
7
votes
1 answer

Rails 4 + Rolify Gem: User roles aren't being updated via UI

I have an edit view that allows me to update roles for a particular user. I've included the code below, however, just to give you an idea, when I uncheck the boxes on the page, my puts statements in my controller correctly picks up that the role…
Ryan Drake
  • 359
  • 3
  • 17
6
votes
1 answer

How to avoid N+1 in Pundit policy for show?/update?/destroy?

I'm using ActiveAdmin gem together with Pundit (and Rolify) gem. This is how I wrote my policy (taken from: https://github.com/activeadmin/activeadmin/blob/master/spec/support/templates/policies/application_policy.rb): class ApplicationPolicy …
Viktor
  • 2,982
  • 27
  • 32
6
votes
3 answers

Rails 4 - Pundit with Rolify - permitting a group of roles

I am trying to make an app with Rails 4. I have defined a series of roles with Rolify gem. Now, I want to use pundit to allow users with a role to do certain things. Where more than one type of role can do a thing, I have defined a group of…
Mel
  • 2,481
  • 26
  • 113
  • 273
6
votes
2 answers

What's the point of Rolify and CanCan?

I'm working on a RoR project and I'm a little confused about this new gem that was recommended for my purposes, Rolify. As I understand it, rolify does pretty much the same thing as CanCan except it persists abilities (roles for rolify) to the…
Dylan Karr
  • 3,304
  • 4
  • 19
  • 29
5
votes
3 answers

How do you add roles rolify using cancan and devise?

I get that there are a lot of questions on this subject but none have really answered what i'm looking for. I'm attempting to use rolify to define my roles in cancan, i was able to make an admin role via rails console and set the default role for…
user922592
5
votes
4 answers

Rolify remove_role deletes from role table?

This is strange. I'm using Rolify + CanCan + Devise in my rails 3.2 app. My use case is simple. I want a user to have only one role at a time, thus to change a role, I do something like this: user.remove_role "admin" user.add_role…
user3009646
  • 51
  • 1
  • 3
5
votes
1 answer

What is the purpose of Rolify?

Hi I'm using rolify and have just realized that I'm not actually taking advantage of it's full potential. At present I am doing things in my controller like re-routing users if current_user.has_role? :whatever_role, and allowing users if they have…
Chris Keele
  • 3,364
  • 3
  • 30
  • 52
4
votes
1 answer

CanCanCan show only instance of model that user belongs to

I'm currently using Devise, CanCan, and Rolify to handle authentication and authorization for my rails app and I'm having a really hard time understanding how to make it so that a user can only :show and :update a specific instance of a model that…
cdouble.bhuck
  • 507
  • 1
  • 5
  • 19
4
votes
2 answers

Rolify and getting a list of User with specific access to a resource

I have two models Organization and Users which I'm using Rolify to connect. Users have roles and Organization is a resource. This works great however my problem is trying to get a list of users for a particular resource. I would like to get a list…
ere
  • 1,739
  • 3
  • 19
  • 41
4
votes
1 answer

Rolify fixtures setup for rails app

Have an app where i'm using Rolify and Pundit for authorization and Minitest/fixtures for testing. When i setup a user as administrator using fixtures, i'm not getting back a true for an assertion. /fixtures/users.yml administrator: email:…
Austio
  • 5,939
  • 20
  • 34
1
2 3
15 16