Creating the routes

We're starting off by just providing the user a simple way to sign up; we will essentially just be displaying a new users page with a form and then showing some sort of profile page for the user. The flow of information in the browser may look something like this:

This will help us figure out how to create the routes for our application. If we're following a strictly RESTful design methodology, then the signup page should be a new route on the user's resource. Creating the user (clicking Submit on our form) would be a POST to the user's resource, with the body being the user we're trying to create. Finally, if successful, we'll show the created user (something like a user profile, essentially) back out to the user. If we were thinking about this strictly from the perspective of our Phoenix routes definition, we would expect it to look something like this:

    get "/users/new", UserController, :new
get "/users/:id", UserController, :show
post "/users", UserController, :create

We'll need a UserController to route these requests and three new functions: new, show, and create. We can create lib/vocial_web/controllers/user_controller.ex and start it off with a pretty basic skeleton.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset