pundit

authorization rails_admin with pundit

偶尔善良 提交于 2021-02-07 08:27:46
问题 I use pundit gem to authorization. In my file config/initializers/rails_admin.rb RailsAdmin.config do |config| config.authorize_with :pundit config.current_user_method(&:current_user) ...... end I follow the instructions in https://github.com/sudosu/rails_admin_pundit But in when run code, error : protected method `policy' called for #<Rails_Admin::MainController I use rails_admin 0.8.1 Please guide me use pundit in rails_admin ( tutorial, examle, ...) 回答1: You can try to use this gem or just

authorization rails_admin with pundit

放肆的年华 提交于 2021-02-07 08:25:17
问题 I use pundit gem to authorization. In my file config/initializers/rails_admin.rb RailsAdmin.config do |config| config.authorize_with :pundit config.current_user_method(&:current_user) ...... end I follow the instructions in https://github.com/sudosu/rails_admin_pundit But in when run code, error : protected method `policy' called for #<Rails_Admin::MainController I use rails_admin 0.8.1 Please guide me use pundit in rails_admin ( tutorial, examle, ...) 回答1: You can try to use this gem or just

authorization rails_admin with pundit

自作多情 提交于 2021-02-07 08:24:35
问题 I use pundit gem to authorization. In my file config/initializers/rails_admin.rb RailsAdmin.config do |config| config.authorize_with :pundit config.current_user_method(&:current_user) ...... end I follow the instructions in https://github.com/sudosu/rails_admin_pundit But in when run code, error : protected method `policy' called for #<Rails_Admin::MainController I use rails_admin 0.8.1 Please guide me use pundit in rails_admin ( tutorial, examle, ...) 回答1: You can try to use this gem or just

authorization rails_admin with pundit

感情迁移 提交于 2021-02-07 08:24:32
问题 I use pundit gem to authorization. In my file config/initializers/rails_admin.rb RailsAdmin.config do |config| config.authorize_with :pundit config.current_user_method(&:current_user) ...... end I follow the instructions in https://github.com/sudosu/rails_admin_pundit But in when run code, error : protected method `policy' called for #<Rails_Admin::MainController I use rails_admin 0.8.1 Please guide me use pundit in rails_admin ( tutorial, examle, ...) 回答1: You can try to use this gem or just

Pundit policies with two input parameters

落花浮王杯 提交于 2021-02-06 15:32:32
问题 I'm pretty new with Rails and I have a problem with the following policies (using Pundit): I'd like to compare two objects: @record and @foo , as you can see here: class BarPolicy < ApplicationPolicy def show? @record.foo_id == @foo end end I don't reach to find a good way to pass a second parameter to pundit methods (@foo). I'd like to do something like: class BarsController < ApplicationController def test authorize bar, @foo, :show? # Throws ArgumentError ... end end But the Pundit

Pundit policies with two input parameters

女生的网名这么多〃 提交于 2021-02-06 15:32:09
问题 I'm pretty new with Rails and I have a problem with the following policies (using Pundit): I'd like to compare two objects: @record and @foo , as you can see here: class BarPolicy < ApplicationPolicy def show? @record.foo_id == @foo end end I don't reach to find a good way to pass a second parameter to pundit methods (@foo). I'd like to do something like: class BarsController < ApplicationController def test authorize bar, @foo, :show? # Throws ArgumentError ... end end But the Pundit

Pundit policies with two input parameters

橙三吉。 提交于 2021-02-06 15:32:07
问题 I'm pretty new with Rails and I have a problem with the following policies (using Pundit): I'd like to compare two objects: @record and @foo , as you can see here: class BarPolicy < ApplicationPolicy def show? @record.foo_id == @foo end end I don't reach to find a good way to pass a second parameter to pundit methods (@foo). I'd like to do something like: class BarsController < ApplicationController def test authorize bar, @foo, :show? # Throws ArgumentError ... end end But the Pundit

Rails - Pundit - how to check for current_admin_user?

送分小仙女□ 提交于 2021-01-29 06:36:56
问题 I am using Pundit for authorization for my User model. My goal is to extend this to use my AdminUser model, specifically for my admin namespace. By default, Pundit checks for a "user" or "current_user". How can I change this to check for a "admin_user" or "current_admin_user", based on Devise? policies/admin/admin_policy.rb (Closed system, currently looks for User instead of AdminUser) class Admin::AdminPolicy attr_reader :user, :record def initialize(user, record) # Must be logged in raise

Use Pundit with strong parameters in Rails API

无人久伴 提交于 2020-01-16 12:03:18
问题 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: # posts_controller.rb def update if @post.update(permitted_attributes(@post)) render jsonapi: @post else render jsonapi: @post.errors, status: :unprocessable_entity end end private def set_post @post = Post.find(params[:id]) end def post_params

Use Pundit with strong parameters in Rails API

百般思念 提交于 2020-01-16 12:02:46
问题 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: # posts_controller.rb def update if @post.update(permitted_attributes(@post)) render jsonapi: @post else render jsonapi: @post.errors, status: :unprocessable_entity end end private def set_post @post = Post.find(params[:id]) end def post_params