module Pundit::ActionHelpers(T)
Overview
A set of helpers that can be included in your Lucky BrowserAction
and made available to all child actions.
Defined in:
pundit/action_helpers.crInstance Method Summary
-
#current_user : T | Nil
Pundit needs to leverage the
#current_user
method for implicit authorization checks
Macro Summary
-
authorize(object = nil, policy = nil, query = nil)
The
authorize
method can be added to any action to determine whether or not the#current_user
can take that action.
Instance Method Detail
abstract
def current_user : T | Nil
#
Pundit needs to leverage the #current_user
method for implicit authorization checks
Macro Detail
The authorize
method can be added to any action to determine whether or not the #current_user
can take that action.
In its simplest form, you don't have to provide any parameters:
class Books::Index < BrowserAction
get "/books" do
authorize
html Books::IndexPage, books: BooksQuery.new
end
end
This is equivalent to replacing authorize
with BookPolicy.new(current_user).index? || raise Pundit::NotAuthorizedError