Skip to content

Nested resource route doesn't pass parameters #779

Closed

Description

@chasm

I'm using Ember CLI with EmberScript, Emblem, and Stylus. In my router, if I have this:

Router.map ->
  @resource "users", ->
    @route "new"
    @resource "user", { path: ':id' }, ->
      @route "edit"

I cannot access the :id segment via params (params is empty) in the 'user' route (not edit). I've tried this a dozen different ways. On the other hand, if I do this:

Router.map ->
  @resource "users", ->
    @route "new"
    @route "user", path: ':id'
    @route "edit", path: ':id/edit'

It works fine. So that's my current workaround. But everything I see suggests that the first example should work just fine. Am I missing something, or is this broken?

Activity

  1. rwjblue commented on May 20, 2014

    @rwjblue
    Member

    In the first example you gave, I would expect app/routes/user.js to be used, and in the second app/routes/users/user.js. The fact that this.resource resets the namespace/scope confuses some folks, so I am just trying to make sure that isn't what is going on here.

    Where (on disk) is the route you are trying to get the params from?

  2. chasm commented on May 21, 2014

    @chasm
    Author

    You can see the failing code itself.

  3. jgwhite commented on May 21, 2014

    @jgwhite
    Contributor

    Hey Charles, how’s it going?

    It looks like you don’t have a user route to match up with the user resource. That’s the one that’d typically turn the id param into a model.

  4. chasm commented on May 21, 2014

    @chasm
    Author

    Not so good, JG. I cannot understand what you're saying. Can you be more explicit, perhaps with code? I am looking at the above code snippets and it sure looks to me like there is a user route. Or do you mean that the user resource is not the same as a route? Can you give me an example of what this might look like? The Ember documentation is missing a simple example of standard CRUD in a RESTY manner.

    TIA!

  5. jgwhite commented on May 21, 2014

    @jgwhite
    Contributor

    @chasm I’ll has a look and make a PR

  6. chasm commented on May 21, 2014

    @chasm
    Author

    Yay!

  7. chasm commented on May 21, 2014

    @chasm
    Author

    Excellent! Thank you much. I had been playing around with the * and the .index -- those weren't the issue. The issue was moving the route out of users/ and renaming it. I'd renamed it, but left it in the users/ folder or in the user/ folder. I can sort of see why it is this way (but I'm going to be honest and say that this directory structure is ugly and will be difficult for students). My bad on the issue. I had tried so many combinations that I figured it might be an emberscript thing...

  8. jgwhite commented on May 21, 2014

    @jgwhite
    Contributor

    @chasm there is an alternative — the “pods” structure (as described here) works today. Have a play with that if you’re feeling adventurous 😄

  9. jgwhite commented on May 21, 2014

    @jgwhite
    Contributor

    Can probably close this issue now, right?

  10. chasm commented on May 21, 2014

    @chasm
    Author

    Yes

    Jamie White mailto:[email protected]
    May 21, 2014 at 5:54 PM

    Can probably close this issue now, right?

    —
    Reply to this email directly or view it on GitHub
    #779 (comment).

  11. chasm commented on May 21, 2014

    @chasm
    Author

    Yup! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions