Questions tagged [pundit]

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.

439 questions
0
votes
1 answer

How to add a model for the roles listed in the enum in Rails?

I am using devise and Pundit in my application. I have many users like Student, Teacher, Admin, Editor. I added a enum role in my User devise model. Now the part i am not understanding is - student will have its own attributes, likewise teachers…
Zaa
  • 23
  • 8
0
votes
2 answers

Pundit: how to handle multiple error codes for one unauthorized action?

I use pundit to handle my API policies, I have an item show that can be forbidden to user in some cases, and in other cases just restricted. By restricted I mean it's forbidden now, but if he pays he could access it then. So I need my API to respond…
adesurirey
  • 2,549
  • 2
  • 16
  • 36
0
votes
0 answers

I get this error I usually know how to resolve it but doesn't work Pundit::AuthorizationNotPerformedError in SavedHairstylesController#create

Context: I am creating a bookmark feature for my app and it seems to be running and then it hits the Pundit error Pundit::AuthorizationNotPerformedError in SavedHairstylesController#create It's very strange as I have a) generated a policy for my…
Angela Inniss
  • 359
  • 1
  • 2
  • 18
0
votes
2 answers

my destroy? and upvote? methods not working with Pundit even though I have authorised them

I have just installed Pundit on my app. I have managed to implement pundit for the new create and show methods however when it comes to my destroy and up vote methods I get the following error Pundit::NotDefinedError in HairstylesController#upvote…
Angela Inniss
  • 359
  • 1
  • 2
  • 18
0
votes
0 answers

RSpec test passing individually, failing whole suite

I have been having a problem with my Rails api. The offender: context 'as a publisher' do before { create(:invitation_post) } it 'shows posts whose invitations are to you' do authorise publisher # helper which adds an authentication token…
johansenja
  • 568
  • 1
  • 7
  • 18
0
votes
1 answer

Pundit::NotAuthorizedError - ApplicationPolicy inheritance doesn't work

I am installing pundit on my app. My RestaurantPolicy file inherits from the ApplicationPolicy one (which by default gives access to none of the methods). When changing the methods in RestaurantPolicy (from false to true) it seems to have no effect…
Julie
  • 25
  • 2
  • 10
0
votes
0 answers

Flash not shown with i18n

My flash message doesn't show when I use i18n, but does when I just use a string. This is in the application controller. This works: def user_not_authorized(exception) policy_name = exception.policy.class.to_s.underscore ## require 'pry';…
puredevotion
  • 1,135
  • 1
  • 11
  • 27
0
votes
1 answer

Does railsapps (rails-devise-pundit) apps have multiple role support baked in?

In a stock "rails-devise-pundit" application generated using "railsapps", does it include support for adding multiple roles for users? A can I make John Doe have a :user role plus an :admin role
american-ninja-warrior
  • 7,397
  • 11
  • 46
  • 80
0
votes
1 answer

pundit rails 5 can't enforce create method restrictions

everytime I submit a form here (that I scaffolded) localhost:3000/syllabus_requests/new The rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized from my ApplicationController.rb file gets raised and I'm not sure why because in the…
0
votes
2 answers

Rails 5, pundit authorization

Pundit works well, if action has resources like: class Admin::PagesController << ApplicationController def index @pages = Page.all end end How to authorise method without any resources in action? class Admin::DashboardController <<…
sssebaaa
  • 75
  • 1
  • 9
0
votes
2 answers

How to solve NoMethodError with Pundit

I don't know if I'm doing something wrong here but it seems like. I use Pundit for authorization and I have set up a few models with it now. Ive got a Category model which can only be created by admins. Also I don't want users to see the…
benl96
  • 274
  • 3
  • 18
0
votes
1 answer

Rails_admin and rails_admin_pundit error after upgrade to 5.2.1

NoMethodError at / protected method `policy' called for # Did you mean? policies Here's the first thing it looks at in the error page (this is in the gemfile code) # This method is called to find…
mazing
  • 603
  • 1
  • 6
  • 21
0
votes
1 answer

adding pg search to index page but having pundit issues

im trying to add pg search to my tweets index page, to search for tweets and users, however im having some pundit issues when i search. I've tried to set my tweet policy to return true on the index page but nothing changes. ive tried to look on…
b.herring
  • 563
  • 2
  • 18
0
votes
1 answer

Pundit: Proper way to gain access based on joiner table

A bit new to Pundit. I have 3 models and a joiner table; a User, Customer and Route model, and a joiner table that allows users to have a route. Customers belongs to specific routes. I just want authorize a user to see a customer if she/he has a…
pzin
  • 4,200
  • 2
  • 28
  • 49
0
votes
1 answer

Using scopes in my Pundit policy (Rails 5)

How to use scopes, defined in the model, in my Pundit policy? In my model I have a scope: scope :published, ->{ where.not(published_at: nil )} And in my Pundit policy I have class CompanyPolicy < ApplicationPolicy def index? true …
userden
  • 1,615
  • 6
  • 26
  • 50