Adding resources produced by tips doesn't change output of phx.routes

I follow these tips produced by mix phoenix.gen.html:

> mix phoenix.gen.html Post posts title:string body:text
...
Add the resource to your browser scope in web/router.ex:

    resources "/posts", PostController

Remember to update your repository by running migrations:

    $ mix ecto.migrate

web/router.ex doesn’t exist under project directory, so I create web/router.ex only containing text:

resources "/posts", UserController

and execute mix ecto.migrate
But output of mix phx.routes doesn’t change. Am I right to add resources?

A new foo Phoenix project will have 2 folders inside the lib directory:

  • foo
  • foo_web

router.ex is in lib/foo_web/router.ex (notice foo_web, not web or anything else). Perhaps the tips should be updated to be more clear on the following steps (I’ve missed the use of the older phoenix generator instead of phx).

It seems You are mixing version of Phoenix. It’s fine to use mix phoenix.gen.html with older version (1.2) but with 1.3 You should use mix phx.gen.html.

4 Likes

Fixed, thanks :slight_smile: