Skip to content

Commit

Permalink
Update README to include note on reloading guest_user
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmenden committed Nov 9, 2023
1 parent 85b2bc4 commit 152d44a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ guest_user # ( for anonymous users)

### Transferring Guest to User on Login

During the login process you may want to transfer things from your guest user to the account the logged into.
During the login process you may want to transfer things from your guest user to the account they logged into.
To do so, add the following method to your ApplicationController:

```ruby
Expand All @@ -58,6 +58,10 @@ def transfer_guest_to_user
else
guest_user.cart.update!(user: current_user)
end

# Note: you may want to call `guest_user.reload` at the end of this
# function to ensure any dependent hooks (destroy, nullify, etc)
# are not run from the guest_user's outdated associations
end
```

Expand Down

0 comments on commit 152d44a

Please sign in to comment.