Skip to content

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

Open
ghost wants to merge 1 commit into
remi:masterfrom
bredband2:nested_create_issue_224
Open

Proposed solution to issue #224, getting the expected request_path when ...#238
ghost wants to merge 1 commit into
remi:masterfrom
bredband2:nested_create_issue_224

Conversation

@ghost

@ghost ghost commented May 5, 2014

Copy link
Copy Markdown

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

planas commented Jul 25, 2014

Copy link
Copy Markdown

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

@kinopyo

kinopyo commented Sep 10, 2014

Copy link
Copy Markdown

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
Copy Markdown

seems to do the job 👍

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

@kindrowboat

Copy link
Copy Markdown
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

chewi commented Feb 13, 2015

Copy link
Copy Markdown
Contributor

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

chewi commented Sep 30, 2016

Copy link
Copy Markdown
Contributor

@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