Skip to content

Commit

Permalink
doc: use switch_user instead of switch_account
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanural authored and Burgestrand committed Nov 22, 2024
1 parent 03392c9 commit cd6bff9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,20 @@ 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.
If you need to change the context for any reason, you will need to clear the caches stored in the Pundit. You can use the hook below to do this.

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

def switch_account
set_current_account(Account.find(params[:account_id]))
set_current_user(User.find(params[:user_id]))
pundit_reset!
end

def pundit_user
UserContext.new(current_user, current_account)
UserContext.new(current_user, request.ip)
end
end
```
Expand Down

0 comments on commit cd6bff9

Please sign in to comment.