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

Proposed solution to issue #224, getting the expected request_path when ... #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@ghost ghost commented May 5, 2014

...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.

@ghost ghost closed this May 13, 2014
@ghost ghost reopened this May 13, 2014
@ghost ghost mentioned this pull request May 16, 2014
@planas
Copy link

planas commented Jul 25, 2014

Hi there, is this going to be merged at some point? If not it would be a good idea to fix the readme

@kinopyo
Copy link

kinopyo commented Sep 10, 2014

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?

@rwojsznis
Copy link

seems to do the job 👍

adding this thread to watchlist and waiting for merge & new release :)

@kindrowboat
Copy link
Contributor

It seems to me that this path would only get used once (i.e. for the #create or first #save, but then be deleted and not used in subsequent requests).

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 /users/:user_id/comments/:comment_id.

Perhaps this should be set as a instance variable (instead of a temporary attribute) on the model, so that it can be used repeatedly.

@chewi
Copy link
Contributor

chewi commented Feb 13, 2015

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.

@chewi
Copy link
Contributor

chewi commented Sep 30, 2016

@edtjones, if you're looking at this one, I'd really appreciate having a chat with you about it.

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

Successfully merging this pull request may close these issues.

6 participants