Skip to content
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

Problem with optimistic locking wiki page "Example functionality" section. #824

Closed
coblej opened this issue Feb 10, 2020 · 2 comments
Closed

Comments

@coblej
Copy link

coblej commented Feb 10, 2020

The “Example functionality” section of this wiki page — https://github.com/samvera/valkyrie/wiki/Optimistic-Locking — doesn't demonstrate what it is intended to, since the initial resource is only instantiated, not persisted. Hence the two 'change_set_persister.save' lines in the body of the example don’t create a StaleObjectError . Rather they create (persist) two different instances of the resource.

I'll provide a proposed alternative code example in a comment.

@coblej
Copy link
Author

coblej commented Feb 10, 2020

Actually, I think that all that's needed is to add this line resource = Valkyrie.config.metadata_adapter.persister.save(resource: resource) after the existing resource = MyLockingResource.new(title: "test title 1") line, so that the first block looks like this ...

# Create a resource
resource = MyLockingResource.new(title: "test title 1")
resource = Valkyrie.config.metadata_adapter.persister.save(resource: resource)

@tpendragon
Copy link
Collaborator

I applied those changes. Thanks @coblej !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants