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

Add rootModel setting to RESTAdapter #2717

Closed
wants to merge 1 commit into from
Closed

Conversation

funtusov
Copy link
Contributor

This would add support for REST API's with embedded models:

If post has many comments, then

# /app/adapters/comments
export default ApplicationAdapter.extend({
  rootModel: 'post'
});

would generate /posts/:post_id/comments/:id as the url

Embedded models often cannot be accessed by id directly (i.e. mongodb) and many API's use something along the lines of:

Post.find(params[:post_id]).comments.find(params[:id])

To access embedded models.

That's something I use and it seems it's quite widely requested:

The alternative is the pathTemplate RFC: emberjs/rfcs#4

It seems that a single nested nesting covers most cases and is along the lines of how other properties are set on the adapter.

@tomdale
Copy link
Member

tomdale commented Feb 6, 2015

I like the idea in theory, but I think that in practice it does not save that much typing, and having two ways to specify a URL template seems confusing. In general, we'd prefer to have one way to do something rather than several.

Thank you so much for the PR, and let's keep the discussion going if you feel like the path template RFC does not satisfy your needs.

@tomdale tomdale closed this Feb 6, 2015
@runspired runspired added 🏷️ feat This PR introduces a new feature and removed Feature labels Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ feat This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants