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
1
vote
1 answer
Rails - with Pundit Scopes in policy
I am trying to figure out how to use pundit policy scopes in my article policy.
I have written an article policy, that nests a scope and then has a resolve method in it. The resolve method has alternatives based on who the current_user is.
My…

Mel
- 2,481
- 26
- 113
- 273
1
vote
1 answer
Rails 4 - Pundit - policies not working
I'm trying to figure out how to use Pundit in my Rails 4 app.
I have a project model, with a projects controller that has a new action in it:
def new
# a bunch of stuff in the new action that I don't think is very relevant here
end
I then have a…

Mel
- 2,481
- 26
- 113
- 273
1
vote
1 answer
Pundit::NotDefinedError: unable to find policy when moving from Pundit 0.3 to 1.0
When I am running rspec wit pundit version 1.0 on one of my project spec classes I get multiple errors which I haven't seen before. However, when I'm switching to the previous version of pundit (0.3) everything works correctly.
Up to now what I have…

yqbk
- 706
- 2
- 7
- 15
1
vote
2 answers
Pundit scoping usage empty results
Suppose I have a scenario where we have Users and each user can create their own Projects.
I'm trying to limit the Show action of my Rails controller to only allow admin or the owner of the project to be able to go through Show action.
The problem I…

Zhang
- 11,549
- 7
- 57
- 87
1
vote
0 answers
Rails pundit authorize specific controller actions
So I'm using Pundit to check for authorization access.
Before each controller in my application, I have
class ReservationsController < ApplicationController
before_action :authorize_reception!
With the helper module:
module AuthorizeMethods
def…

fedest
- 1,190
- 3
- 15
- 35
1
vote
1 answer
How can I re-raise a Ruby exception in a Rails rescue_from statement?
My Rails 4 app uses RocketPants for its JSON API and Pundit for authorization.
I have code in my /app/controllers/api/v1/base_controller.rb file to handle errors from Pundit. Whenever a user isn't authorized to update a resource, Pundit throws a…

Rob Sobers
- 20,737
- 24
- 82
- 111
1
vote
0 answers
rails controller tests for nested polymorphic resources
As many times that I've tried to do rails testing, you'd think I had figured it out by now - I haven't.
The latest approach is using minitest - at least it's mainly Ruby and not a bunch of DSL that is learning yet another language with what seems…

appleII717
- 328
- 3
- 12
1
vote
1 answer
ERR_TOO_MANY_REDIRECTS logging in with OmniAuth/Devise/Rails
I'm attempting to add Facebook login to my Rails 4 site following these instructions:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
I'm currently using Devise and Pundit for authorization and authentication. Despite having followed…

Captain Stack
- 3,572
- 5
- 31
- 56
1
vote
1 answer
Pundit: authorize actions within namespaced controllers
I have a Blog model which has different states. In order to keep a skinny controller and follow the convention of only having CRUD operations per controller, I followed DHH's namespacing controllers pattern and namespaced out the Blog controller. …

Neil
- 4,578
- 14
- 70
- 155
1
vote
1 answer
Setting Default Role using Enum based on Project creation
I have a Projects and a Relationships model to establish a 'following' relationship between a user and a project. I established three roles for the 'Relationship' using enum in the relationship model...they are admin, collaborator, and visitor. I…

BB500
- 549
- 2
- 6
- 24
1
vote
1 answer
Pundit::AuthorizationNotPerformedError attempting to adapt microposts to Devise/Pundit
I'm new to Rails and I'm working through Michael Hartl's excellent Rails Tutorial for a second time, this time I'm trying to adapt the chapter 11 and chapter 12 microposts to a simple Devise/Pundit application I'm working on. I am able to create…

mack
- 2,715
- 8
- 40
- 68
1
vote
1 answer
Authorize record associations in pundit
How do we go about authorizing associations when creating and updating records with pundit in rails.
For example if we're updating a comment record that belongs to a post, we need to make sure the user has the permission to access that post or else…

Raz
- 8,981
- 4
- 19
- 18
1
vote
1 answer
Switching Apartment tenants in Active Admin
This is an extension of my previous post:
Active Admin and the Apartment Gem
I thought I had this working but I am stuck. I have a Company model in the public schema as the tenant model and Locations in individual tenants. Here is my Active Admin…

Dan Tappin
- 2,692
- 3
- 37
- 77
1
vote
1 answer
Scope for nested resources using pundit
I have the following relations:
class Patient < ActiveRecord::Base
belongs_to :user
has_many :analyses, dependent: :destroy
end
class Analysis < ActiveRecord::Base
belongs_to :patient
end
To use scopes in Patient is simple, I just did:
…

Mario
- 1,213
- 2
- 12
- 37
1
vote
1 answer
pundit for rails trouble configuring
I have built a web app using rails 4.2.4, devise and a pins scaffolding where users can CRUD a pin.
I am about to medicate myself trying to get pundit working so that only the Admin can CRUD a pin, all users signed in or guests can only view and…

Chris Dormani
- 476
- 8
- 21