Pundit::ActionHelpers(T)
A set of helpers that can be included in your Lucky BrowserAction and made available to all child actions.
Instance methods
current_user
Pundit needs to leverage the current_user method for implicit authorization checks
Macros
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.
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