Pundit provides a set of helpers that guide Ruby programmer in leveraging regular Ruby classes and object oriented design patterns to build a simple, robust and scaleable authorization system.
Questions tagged [pundit]
439 questions
0
votes
2 answers
Rails scope with complex SQL Statement including OR
I'm working on a small Rails project right now. I'm using Pundit for authorization of controller actions and stuff. The job right now is to use Pundit for the index action and use Pundit's policy_scope in my controller to get the Projects a user can…

bastianwegge
- 2,435
- 1
- 24
- 30
0
votes
2 answers
In rails, defining Pundit scope subclass to display different sets of posts depending on the type of user
Hello, I'm new to ruby on rails, and currently working on an exercise where I have 3 types of users ( Admin, moderator and member). I'm using the Pundit gem with the Devise Gem.
I was asked to define Pundit scope classes to make Posts accessible…

Zein
- 73
- 6
0
votes
1 answer
Pundit rescue_from not redirecting or displaying alert message when non-user accesses posts/new
I'm trying to add authorization to my rails app and want to redirect a non-user to root_url when they try to access posts/new, using rescue_from. However, there is no redirect to root or error message being displayed and I'm not sure why.
This is my…

user3640511
- 167
- 2
- 12
0
votes
2 answers
How to have a rails admin and only 1 admin that can edit & create new posts
I am trying to create a simple page where any visitor can read the weekly posts. I want there to only be 1 admin that can edit or create new posts.
How would I go about creating this?
I started with devise but theoretically anyone can go to the…

coderwannabe2
- 221
- 1
- 2
- 12
0
votes
1 answer
Rails - Pundit undefined method 'user'
I am trying to implement a policy that restricts the creation of a post to either admin or a business. In turn only the record owner(business) who created the post or admin can edit. But i get an error saying 'undefined method user' can anyone help…

Fdwillis
- 1,050
- 9
- 21
0
votes
1 answer
Authlogic and Pundit issue -- Current_user not being populated
Im having the following issue with my site. I'm creating a bunch of api calls that can be used by others but primary the front-end. My issue is for some reason it seems that Authlogic is not authenticating my user before the controller and pundit…

Tom T
- 432
- 1
- 7
- 21
0
votes
1 answer
How can I restrict a user from viewing a page that they don't have access to?
I am taking a course that has me creating a basic wiki. I'm definitely new to this. I need to restrict users from simply typing in a wiki id that they want to view directly in the URL (example: wikis/5). The only people who should be able to view…

Tyler
- 3
- 3
0
votes
1 answer
Pundit is unable to find namespaced policies
I have read several questions on this same topic, but none of them solves my doubts or works for me.
Pundit is unable to find namespaced policies in my code, but I can not understand why. I have a 'backend' namespace, and any time that the…

patriciasc
- 133
- 1
- 7
0
votes
2 answers
Restrict view for various roles in pundit
I am following up from a problem that I had before. I was able to get the code to work for three roles, but I need to include 4 roles in the mix.
The problem: I have 4 roles (user, business user, super user, and admin). Admins have access to…

AGirlThatCodes
- 575
- 7
- 21
0
votes
1 answer
Rolify and Rails 4 role management
I am trying to implement a role based access system in my rails 4 app, and I want the end user (super_admin) to have the ability to edit role assignments via the UI.
I have achieved some success but can't help feeling that there has to be a better…

HermannHH
- 1,732
- 1
- 27
- 57
0
votes
1 answer
Devise-Pundit: Create a page for Superadmin to create users, but it is not actually creating users
How do I enable the Superadmin to actually create Users? Do I need a policy CreateusersPolicy? My code currently takes me to a page/form where I can create a user, but it doesn't actually create the user.
Please let me know if I need to include…

rogue0137
- 21
- 5
0
votes
1 answer
Rails 4 Devise, Pundit, Join Table ActionView::Template::Error (undefined method `task_definition_path' for #<#:0x6919b2b2>):
Here is my use case:
I have one user model with Devise for AuthN and I am using Pundit for AuthZ.
I restrict access to the main application through a subdomain constraint.
I have some pages that are for end users (will be a different LandF at…

Carson City
- 58
- 6
0
votes
1 answer
Rolify has_role? returning true after remove_role
I would like to do the following
User1 = User.find(1)
User2 = User.find(2)
Add a role to users
User1.add_role :teacher
User2.add_role :teacher
User1.has_role? :teacher
>> true
User2.has_role? :teacher
>> true
Delete a role from a specific…

MicFin
- 2,431
- 4
- 32
- 59
0
votes
1 answer
Pundit: undefined method `authorize'
I am trying to use Pundit to authenticate access to some static views that require no database interaction:
class StaticController < ApplicationController
include Pundit
authorize :splash, :home?
def home end
end
Below is my static…

Starkers
- 10,273
- 21
- 95
- 158
0
votes
1 answer
where constraint on a related record
I'm not getting a concept (nothing new there) on how to scope a Active Record query. I want to only receive the records where there is a certain condition in a related record. The example I have happens to be polymorphic just in case that is a…

MechDog
- 508
- 7
- 18