O'Reilly logo

Programming Phoenix by Jose Valim, Bruce Tate, Chris McCord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a Controller

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, but we’re going to play the boring community lifeguard that yells “Walk!” 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 ​"​​/"​, Rumbl ​do
  pipe_through ​:browser
  get ​"​​/users"​, UserController, ​:index
  get ​"​​/users/:id"​, UserController, ​:show
  get ​"​​/"​, PageController, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required