-
Notifications
You must be signed in to change notification settings - Fork 60
Fall back to authorizing update? on related records #70
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
Conversation
This was the functionality present before v1.0.0 and should be kept intact. It is what we want to do — changes to relationships can be though as changing the related records.
|
I'm not really sure what we should authorize in the case when a Here's an example scenario set-up: user_1 = User.create(id: 'user-1')
article_1 = Article.create(id: 'a-1', author: user_1)
or
should both call:
This is, because the reverse way, adding the author, goes like this: article_2 = Article.create(id: 'a-2')
user_2 = User.create(id: 'user-2')
or
...and authorization goes like this for the relationship:
|
|
Also, the above scenario makes me wonder whether it is a good idea to add the Maybe we could do with just the |
|
I think we've now got the same fallback behavior that was part of v0.8.2. The old TODO comment about |
|
I'm gonna ship this as the next alpha version right away. If anyone would like to check out the code and review whether this looks good, I'd appreciate any comments even after this has been merged |
|
Good catch! Thanks for adding this missing fallback.
I think this is a matter of taste. I prefer having the two methods because if you have a scenario where the policies for
Yeah, makes sense. I think it was deleted not having the fallback to |
True. However, this forces users to define two methods instead of just one. It could cause a weird place where first assigning a value to a relationship would be OK (considering I don't really know which approach is better for the library user. All I know that if we'd be OK with sending As I don't have a strong opinion either way, I'm fine with leaving it as it is now, i.e. keep both of the two methods. We could even provide some validator for the policies as a means of increasing developer experience: We could warn if some custom method isn't defined for a relationship, e.g. if there would be a |
This was the functionality present before v1.0.0 and should be kept intact. It is what we want to do — changes to relationships can be thought as changing the related records.
It seems that at some point, this functionality got accidentally lost. The change seems to date to #51
Seems like the reason this slipped through the cracks was that we didn't remember to check these cases back when relationship operation authorization was implemented in #40, so when #51 used the same methods, the old functionality accidentally got lost.