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
Rails 4 migrate cancancan to pundit
I'm trying to migrate to Pundit and having a bit of trouble.
I have a user model and a photo model.
User has many photos and photo is a nested resource of user.
In my controller I do
@user = User.find(params[:user_id])
@photos = @user.photos
In my…

keither78
- 11
- 2
0
votes
1 answer
Rails Gem Pundit isn't blocking users properly
The current user i'm on isn't an admin, however when I hit the new action of the posts controller, I'm able to see it. Why is this? How do I use pundit properly?
From the rails console:
2.1.2 :011 > u.admin?
=> false
post_policy.rb:
class…

Pavan Katepalli
- 2,372
- 4
- 29
- 52
0
votes
1 answer
param is missing or the value is empty on creation
I have a one to one relationship between a User and a Subscription model using Stripe for payments, devise for user authentication and Pundit for roles.
When I create my Subscription model from my create action, I get param is missing or the value…

Hamed Saadat
- 429
- 5
- 8
0
votes
0 answers
Adding Username login to Devise in Rails 4 - Error creating User
Login works fine after following this guide: Allow users to sign in using their username or email address
However creating a new User does no longer work. This is what I am getting:
Started POST "/users" for 10.0.2.2 at 2014-07-30 15:08:49 +0000
…

user3794309
- 15
- 4
0
votes
1 answer
Authorization strategy on a per-client basis
I have a Rails 4 application. I use devise for authentication and opro for providing oauth2 with my API. All requests are authorized with pundit policies and until now, this setup was totally fine.
Currently, my authorization is always done on a…

Peter Sorowka
- 1,036
- 9
- 20
0
votes
2 answers
Rails: defining policy with pundit that depends on which page the user is visiting
I have the same partial in rails that is required in two pages, that shows a list of posts.
The first is a news feed page, the second is a "details" page.
In the first one the user shouldn't be able to edit, in the second he should be able to.
The…

ProGM
- 6,949
- 4
- 33
- 52
0
votes
0 answers
pundit authorizations in a has_many relationship
I'm having some trouble implementing one last step in my pundit authorizations...I have a projects model as well as a project_policy that authorizes which users in the app can view and interact w/ the project. However, my projects have several…

BB500
- 549
- 2
- 6
- 24
0
votes
2 answers
Rails: Log stuff to rails app logs from any ruby class
I want to be able to log things to my Rail's app logs from a ruby class.
I was hoping to do logger.info "some stuff" from a class in my_app/app/myClass.rb, but it's not defined. When I use logger in my controllers and elsewhere it works.
I'm a…

Don P
- 60,113
- 114
- 300
- 432
0
votes
2 answers
How do I resolve a "No Method Error" in my post controller. Devise, Pundit, Blogging app
In trying to set-up policies for my practice app. I'm running into a "No Method Error" in my posts controller.
If we zero in on the post controller and my update method here is the code.
def update
authorize @post
respond_to do |format|
if…

Adam D. Bell
- 157
- 1
- 1
- 8
0
votes
1 answer
Using gem pundit, why author of a post cannot edit or delete it in Ruby on Rails 4.0.2?
I am newbie to rails using ruby 1.9.3 and rails 4.0.2 and pundit 0.2.1
The post model consists of:
belongs_to :user
The user model is generated by using devise gem (and does not have has_many :posts)
devise :database_authenticatable,…

Swapnil Sawant
- 620
- 8
- 21
0
votes
1 answer
Why is my Pundit Policy minitest test case not running with rake test?
I am using Rails 4.1 and the Pundit gem. I created a UserPolicyTest class for my UserPolicy class. But when I run rake test, none of the tests in the class get run. I'm also trying to use mini-test. I cannot find any documentation on what the parent…

Mike F.
- 69
- 1
- 9
0
votes
1 answer
rails3 Pundit policy base on join table value
User has_many constructusers, the latter being a join table for a has_many :through relationship to Construct. For the application purposes, the boolean roles are defined in the join table (constructusers.manager, constructusers.operator, etc.),…

Jerome
- 5,583
- 3
- 33
- 76
0
votes
1 answer
Authorize related object when using pundit gem
If I have user object and user has one basicinfo. In user show action I have:
def show
@user = User.find params[:id]
authorize @user
end
And in show.html.erb I must show user's basicinfo, such as:
User name is: <%= @user.basicinfo.name %>
In…

xnjiang
- 607
- 6
- 16
-1
votes
1 answer
Method with ? in name throws no method errors in pundit policy
I am using Pundit but cannot find how to set a method in my policy that ends with a question mark.
I have a method in my sessions controller called is_logged_in? and in the sessions policy I have the same method with the correct security logic…

gwnp
- 1,127
- 1
- 10
- 35
-1
votes
1 answer
Rails can a enum role column in User table be referenced in multiple tables?
I have a User model with a Role attribute, which I defined using enum.
enum role: {'Instructor': 0, 'Student': 1, 'Other': 2}
Now, I have another table Instructor with references from User table.
I have a Course table with references from…

Sai Sagar
- 5
- 3