October 2019
Intermediate to advanced
358 pages
8h 22m
English
You’ve already built a simple controller, so you know the drill. At this point, we could create all of the routes needed by a user automatically with the resources macro, but we are going to play the teacher and say “Show your work!” If you understand how a single route works, it’ll be much easier to explore the powerful shortcuts later. Specifically, we need two routes. UserController.index will show a list of users, and UserController.show will show a single user. As always, create the routes in router.ex:
| | scope "/", RumblWeb do |
| | pipe_through :browser |
| | |
| | get "/users", UserController, :index |
| | get "/users/:id", UserController, :show ... |
Read now
Unlock full access