-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update README to include note on reloading guest_user #49
Conversation
Wouldn't a better solution be for those who need to reload the guest record to do so within their |
@pacso I totally understand where you're coming from. Wouldn't you say that it's pretty common for a OK so maybe there are 3 paths forward:
|
In my implementation within my own app, the last thing it does in that function is reload the guest record. However, I still think this is an implementation detail and we shouldn't assume everybody needs to do it. Just because there's a dependent association doesn't mean there's a problem with all of those records getting deleted. I'd be in favour of updating the instructions in the readme and leaving it for people to decide whether they need it or not. |
cef2b5b
to
152d44a
Compare
@pacso Yep I totally get that. Sounds like a good plan. I've just pushed up a commit with an extra note in the README. Let me know if you'd prefer the note to live in a different place in the README and I can push that up as well. Thanks for your timely responses and for maintaining such excellent open source software! |
Hi @pacso just wondering if you have any feedback or comments about the current suggested change. |
Co-authored-by: Jon Pascoe <[email protected]>
@pacso Great change, just committed! |
In the scenario where a
User
record has adependent: :destroy
association, such asWhen you implement
transfer_guest_to_user
like thisYou run into the problem where the dependent
tasks
are still destroyed when theguest_user
is destroyed.Because the
guest_user
in memory that is being destroyed still references thetask
. This can be solved with a simplereload
before destroying the guest_user to make sure that the in-memory record is up to date.I confirmed that this fix works in my Rails app, but I noticed we use
double
for mocking in the specs and it wouldn't feel great to just mock all the functionality to test this use case. If you'd like me to set up a factory and persist some records to the Database to write a test for this I'd be happy to, just let me know.