blackfist
I’m following the directions for the Getting Started project at hexdocs.pm. I’ve gotten to the guide on Contexts here: https://hexdocs.pm/phoenix/contexts.html. I’ve added a resources line to my router.ex so that my “/” scope looks like this:
scope "/", HelloWeb do
pipe_through :browser
get "/", PageController, :home
get "/hello", HelloController, :index
get "/hello/:messenger", HelloController, :show
resources "/products", ProductController
end
But instead of getting routes that point to HelloWeb.ProductController, my routes all point to HelloWeb.HelloWeb.ProductController. Even more strange, if I put in the name of some other non-existent controller I get routes that look the way I expected. Is there something about the generated ProductController that is prepending an extra HelloWeb onto the generated routes?
Any idea what I’m doing wrong here?
EDIT to add an example of what I mean. If I change that line to resources "/products", NilController then my resulting mix phx.routes looks like this:
GET /products HelloWeb.NilController :index
GET /products/:id/edit HelloWeb.NilController :edit
GET /products/new HelloWeb.NilController :new
GET /products/:id HelloWeb.NilController :show
POST /products HelloWeb.NilController :create
PATCH /products/:id HelloWeb.NilController :update
PUT /products/:id HelloWeb.NilController :update
DELETE /products/:id HelloWeb.NilController :delete
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
josevalim
Can you post the full router.exs file?
blackfist
I think I found the problem @josevalim. Either my editor or the context generator or my cat added
alias HelloWeb.ProductControllerto the top ofrouter.ex. When I comment that line out I no longer have the problem.That wont cause any future problems for me if I comment out that second line, will it?
aesmail
Remove the alias in line 2.
It was probably added by the editor automatically (although mistakenly) when you tried to add the resources. This issue happened to me once and I went crazy trying to figure out what happened.
kwando
I hate that feature so much, those auto-added aliases has tripped me up a few times as well. If you don’t see it happen you will start to get errors that doesn’t seem to make any sense at all.