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
1 answer
How to pass the parameter to pundit policy
I am using pundit right now.
But then in my controller, there is a search params with if condition, so I cannot simply use policy_scope to pass the pundit.
Posts_controller
def index
search = params['search']
if search.present?
…

F.k
- 1
0
votes
1 answer
Pundit skip_authorization not working via direct before_action
I have a test that looks like this
test 'should get new' do
get new_organization_url
assert_response :success
end
When I run this test I get an…

JuJoDi
- 14,627
- 23
- 80
- 126
0
votes
1 answer
Pundit authorize mongodb aggregation
I am using Pundit to authorize a model in my controller:
@board = authorize Board.find(id)
However, I have a full() method on my model that calls a mongodb aggregation and returns json. If I try to authorize that I get the error:
unable to find…

I_A
- 331
- 2
- 14
0
votes
0 answers
Can't delete using pundit as user.admin or record.user. How can I get them to delete?
I'm using the Pundit gem for the user authorizations in my Rails project. The Edit function works as I expected, just user admin and whoever created the review is able to update it. However, I can't delete them with the pundit set up.
Here's my…

Norbert
- 103
- 1
- 11
0
votes
1 answer
Rails Pundit ActiveAdmin: page isn’t redirecting properly
I installed Activeadmin and Pundit gems.
Added 'include Pundit' in application_controller.rb.
Defined package_policy.rb
class PackagePolicy < ApplicationPolicy
def update?
user.admin?
end
end
application_policy.rb:
class ApplicationPolicy
…

Vitalina
- 51
- 9
0
votes
2 answers
What's the "rails way" to access a resource in a controller's before_action
I'm using Pundit to authorize actions in my controllers. My first try was to authorize the model in an after_action hoook:
class CompaniesController < InheritedResources::Base
after_action :authorize_company, except: :index
def…

user341493
- 414
- 1
- 7
- 15
0
votes
1 answer
Restrict user role from accessing through url using pundit
I am working on roles and permissions in my application. For this I am using pundit gem. As per the requirement the client_admin role can view users from tested_by column drop down as listed in the below view file but should not be able to access…

user3189916
- 758
- 1
- 7
- 26
0
votes
1 answer
Use Pundit with strong parameters in Rails API
How is it possible to use Pundit strong parameters when working with JSON API if a model contains some relations?
I have already posted a question that explained how to work around with it in case of a single model.
Son here is what works:
#…

belgoros
- 3,590
- 7
- 38
- 76
0
votes
1 answer
Pundit for enum roles
Context
In my app a user.admin can create multiple hotels.
For each of those individual hotels a user.admin can invite one (or more) user.employee or another user.admin.
Therefore, there is a many to many relationship between users and…

techquestion
- 489
- 5
- 20
0
votes
1 answer
Rails API/Pundit: Strong parameters with ActiveModelSerializers
This section of Pundit section says that we could control which attributes are authorized to be updated. But it fails in case of the use of active_model_seriallizers gem:
def post_params
# originally geneated by scaffold
…

belgoros
- 3,590
- 7
- 38
- 76
0
votes
0 answers
User Model Setup for Pundit
I would like to know what is the best setup to make User model for Pundit. (MySQL)
I want:
role: admin, default_user, ..
groups
I find this tutorial:…

Theo Cerutti
- 779
- 1
- 10
- 33
0
votes
1 answer
Identifying the right scope joins for pundit
I'm currently implementing pundit, where I am trying to identify whether or not a user has an admin role.
Issue
I'm trying to avoid creating a join_table between discounts and users, by leveraging the relationship between
discounts and attraction…

techquestion
- 489
- 5
- 20
0
votes
2 answers
Pundit with second devise model
I manage the authorization of users in my app with the pundit gem. Everything works fine for the user. Now I created a second devise model: Employers. I want to show a specific page to both logged in user as well as logged in employers. How do I do…

Sabrina
- 309
- 1
- 14
0
votes
2 answers
Unable to detect error in many to many relationship
I have a bug, that is driving me crazy for a few days now....I set up a many to many relationship between users (created by devise) and parks through table user_parks. When I want to create a new park with a certain user, I get the error message:…

techquestion
- 489
- 5
- 20
0
votes
0 answers
Problem with adding Additional context in pundit
I have a problem where i have to send a session object through the Authorize method in pundit, but the authorize method only supports two parameters, current_user and records
Initially I created a new model named UserParam
class UserParam <…

Sheriff Hussain
- 224
- 2
- 12