# Need a Help with Nested Resources

**URL:** <https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053>\
**Category:** Questions\
**Tags:** phoenix, nested-resources, routerhelpers\
**Created:** [May 4, 2018, 7:54pm UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053 "2018-05-04T19:54:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wlminimal](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/w/958977/32.png) [@wlminimal](https://forum.elixirforum.com/u/wlminimal)\
**Post date:** [May 4, 2018, 7:54pm UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/1 "2018-05-04T19:54:03Z")

</div>

Hello!.  
I am trying to add Nested Resources in router.ex like this..

```
resources "/phonebooks", PhonebookController do
  resources "/people", PersonController, except: [:index]
end

```

and added, templates(using phonebook\_person\_path() ) and controller

and then I did mix phx.routes to see, but it doesn’t compile. it says,

```
== Compilation error in file lib/mmarketing_web/views/dashboard/person_view.ex ==
** (CompileError) lib/mmarketing_web/templates/dashboard/person/new.html.eex:3: undefined function phonebook_person_path/2

```

Please tell me what I am missing ☹

Thank you!

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [May 4, 2018, 9:11pm UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/2 "2018-05-04T21:11:55Z")

</div>

What’s the output of `mix phx.routes`?

---

<div class="post-metadata">

**Author:** ![sweeneydavidj](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sweeneydavidj/32/5892_2.png) [@sweeneydavidj](https://forum.elixirforum.com/u/sweeneydavidj)\
**Post date:** [May 4, 2018, 10:03pm UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/3 "2018-05-04T22:03:44Z")

</div>

I haven’t used nested resources but could it be that in your template you are not passing enough arguments to `phonebook_person_path()`

If you look here…  
[https://hexdocs.pm/phoenix/routing.html#nested-resources](https://hexdocs.pm/phoenix/routing.html#nested-resources)

They have this example …

```
iex> HelloWeb.Router.Helpers.user_post_path(Endpoint, :show, 42, 17)

```

You could try to do something similar from iex to try to debug the problem.

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [May 5, 2018, 7:18am UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/4 "2018-05-05T07:18:02Z")

</div>

I think the best were just to look at the output of `mix phx.routes` as we have complicated pluralisation in this example. We should take a look at what phoenix tries to do from it.

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [May 5, 2018, 9:29am UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/5 "2018-05-05T09:29:21Z")

</div>

I checked on my own (just added the provided snippet in a routes file of mine) and pluralisation seems to work fine.

Then I took a closer look at the error message and have seen, that it is called with only 2 arguments, but it needs 4.

1. the conn or endpoint
2. the action
3. the `phonebook_id`
4. the `id`

---

<div class="post-metadata">

**Author:** ![wlminimal](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/w/958977/32.png) [@wlminimal](https://forum.elixirforum.com/u/wlminimal)\
**Post date:** [May 7, 2018, 2:49am UTC](https://forum.elixirforum.com/t/need-a-help-with-nested-resources/14053/6 "2018-05-07T02:49:59Z")

</div>

Thanks! it compiles!  
I i didn’t know I had to pass 2 more arguments including conn, and action.
