-
Notifications
You must be signed in to change notification settings - Fork 323
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
Proposed solution to issue #224, getting the expected request_path when ... #238
base: master
Are you sure you want to change the base?
Conversation
…h when creating a nested resource
Hi there, is this going to be merged at some point? If not it would be a good idea to fix the readme |
same here wondering what's the status, seems a missing feature or common gotcha. will use this fork for a while and see if there's any side effects. meanwhile @remiprev could you please take a look and give some feedbacks when you have time? |
seems to do the job 👍 adding this thread to watchlist and waiting for merge & new release :) |
It seems to me that this path would only get used once (i.e. for the Example (not tested): comment = @user.comments.create( body: "Your really bad at grammar" ) # POST /users/:user_id/comments
comment.body = "You're really bad at grammar".
comment.save # PUT /comments/:comment_id Is that the desired behavior? I know for our APIs we would make subsequent PUTS to Perhaps this should be set as a instance variable (instead of a temporary attribute) on the model, so that it can be used repeatedly. |
I'm not sure that this is such a good idea. Having an association doesn't necessarily mean that the parent path should be prepended like this. It really depends on the API. You can work around it by explicitly defining the collection_path but you may have noticed that this doesn't work for nested associations. I have fixed this in #318. On the other hand, if you need to access a model directly as well as through an association then setting collection_path won't help. This is a tricky one. Maybe we need to be able to explicitly state the path that is used for direct access, if there is one, as well as the path used for each association. These paths could all be the same in some cases or they could all differ. |
@edtjones, if you're looking at this one, I'd really appreciate having a chat with you about it. |
...creating a nested resource
This solution follows along the lines of what you do with the parent id and includes the parent request path when building the resource.
Please give some feedback on this, if it's a fair solution, if something is missing. I would like your thought on this.