wlminimal

wlminimal

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 :frowning:

Thank you!

Showing Posts 1 to 5

NobbZ

NobbZ

What’s the output of mix phx.routes?

sweeneydavidj

sweeneydavidj

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

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.

NobbZ

NobbZ

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.

NobbZ

NobbZ

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
wlminimal

wlminimal OP

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

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews