Skip to content

Commit

Permalink
Add instructions to Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanural authored and Burgestrand committed Nov 22, 2024
1 parent 688c6a8 commit e234c02
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,24 @@ class ApplicationController
end
```

If you need to change the context for any reason, you will need to clear the caches stored in the context. You can use the hook below to do this.

```ruby
class ApplicationController
include Pundit::Authorization
before_action :switch_account, if: :should_switch_account?

def switch_account
set_current_account(Account.find(params[:account_id]))
clear_pundit_context!
end

def pundit_user
UserContext.new(current_user, current_account)
end
end
```

## Strong parameters

In Rails,
Expand Down

0 comments on commit e234c02

Please sign in to comment.