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
0
votes
2 answers

Undefined local variable or method 'rolify'

In my Rails project, I am trying to set up user authentication and user roles using the following Gems: Devise Cancan Rolify I had Devise up and working perfectly, but then when I went to set up CanCan and Rolify, I get this error in the browser:…
Keenan Payne
  • 796
  • 2
  • 15
  • 32
0
votes
1 answer

CanCan/Rolify gives incorrect Ability results

Given the following Ability; class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest if user.has_role? :project_lead can :read, Project, :id => Project.with_role(:project_lead, user).pluck(:id) …
mvanio
  • 505
  • 3
  • 15
0
votes
1 answer

Why i am getting undefined local variable or method `role' in cucumber test cases

following error i am getting And I am exists as a parent # features/step_definitions/kid_steps.rb:106 undefined local variable or method `role' for # (NameError) …
atish
  • 39
  • 8
0
votes
0 answers

Devise: Foreign key columns for roles in user_id

I used rails composer to create a starter app for my rails project. It is using devise to create and manage roles I have following roles for my User: Recruiter, Applicant A User can one or both of [Recruiter, Applicant] I looked at the User model…
codeObserver
  • 6,521
  • 16
  • 76
  • 121
0
votes
1 answer

How to authorize a specific page with CanCan and Devise?

I have a resource for students with CRUD methods. Only people with certain roles can read, update, manage, etc the students resource. I specified that in my ability.rb file. However, now I want students (who normally have no access to the students…
at.
  • 50,922
  • 104
  • 292
  • 461
0
votes
2 answers

Rolify abilities returning false

I'm experiencing a strange issue using Rolify (click for tutorial I'm following) with Rails: The can method does not seem to work, therefore rendering user privileges unuseable. Below is my ability.rb file and console output where the problem is…
Tomanow
  • 7,247
  • 3
  • 24
  • 52
0
votes
1 answer

How do I restrict the currently logged in user to only see products that belong to them?

If a user is logged in with a specific role - vendor - they should only see items that they have created in their store. They should not be able to see products from other vendors. So I am trying to do this in my authorization (using Devise, CanCan,…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
0
votes
1 answer

How do I restrict a role from not seeing prices on Products?

I have a Product model, and if a user is either logged in as a guest role, or not logged in, I don't want them to be able to see the prices on the products in my app. I am using Devise, CanCan and Rolify. I tried this, in my ability.rb: user ||=…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
0
votes
1 answer

Assign admin on user and location create

I have a nested model form for user sign up, which creates a user and a location at the same time. I want the user who creates the location to be assigned the admin role automatically. I'm using devise/cancan/rolify. Any ideas on how to do…
jacobt
  • 157
  • 3
  • 11
0
votes
1 answer

CanCan accessibly_by returns different responses in spec and controller

I am trying to test the user authentication for the Farm model, in this case for the :user role which has read access to all farms when being logged-in (as the guest user aka. anonymous has too). # /models/ability.rb class Ability include…
JJD
  • 50,076
  • 60
  • 203
  • 339
0
votes
2 answers

One rspec roles test fails, but almost identical tests succeeds

I just added the Rolify gem, and am running some rspec tests. 2 tests are as follows: describe "roles" do before(:each) do @user = FactoryGirl.create(:user) end it "should not approve incorrect roles" do @user.add_role…
dewyze
  • 979
  • 1
  • 7
  • 21
0
votes
1 answer

Rolify with_all_roles not working if User model has resource defined

I want to get a list of say moderators from User model, it works in this case u = User.new(:name => "n", :surname => "s", :email => "a@m.c", :password => "x") u.add_role(:moderator) u.save! but if i assign a resource to User model like this, it's…
Said Kaldybaev
  • 9,380
  • 8
  • 36
  • 53
0
votes
1 answer

How do I check for minimum permissions and allow all parent roles permission in a DRY way?

Say I have 4 roles: user, agent, admin, superadmin. Where each role has subsequently more permissions on all objects in my app. I am using Rolify, CanCan & Devise. What I would like to do is, whenever I want to enable something - say: <%= link_to…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
-1
votes
2 answers

How to change default join table name in rolify.rb?

I have dim_user, dim_role and role_user_map tables. I am using rolify gem for authorisation. I don't have role_id as primary key. In my case role_name is the primary key and my role_user_map table will have 2 columns (user_id, role_name) How to…
-1
votes
2 answers

What's the best way to implement roles/permissions to users in a rails app?

Disclaimer: I'm not using Devise, My authentication is being handled using bcrypt. I want to know what are my best options, for the long run in adding roles to my users. For a while my users have been my Company model, and I've been holding off on…
gemart
  • 346
  • 1
  • 3
  • 18
1 2 3
15
16