Skip to content

Instantly share code, notes, and snippets.

@rwarbelow
Created July 24, 2015 19:22
Show Gist options
  • Save rwarbelow/fc48a47d713103b3b66f to your computer and use it in GitHub Desktop.
Save rwarbelow/fc48a47d713103b3b66f to your computer and use it in GitHub Desktop.

Part I: User Creation

  1. add route for new_user_path
  2. create a UsersController with new action
  3. create new.html.erb
  4. generate user model with password_digest string field
  5. uncomment gem 'bcrypt' in Gemfile and add has_secure_password in User model
  6. add create action in UsersController
  7. implement logic for creating a user
  8. set session[:user_id] in create action
  9. add route for user_path (the show action)
  10. addshow action in UsersController
  11. add show.html.erb
  12. create current_user helper method in ApplicationController

Part II: Logging in

  1. add login route
  2. create SessionsController
  3. add new action in SessionsController
  4. add new.html.erb
  5. make login form in new.html.erb
  6. add post route for login
  7. add create action in SessionsController
  8. implement create action: find user, authenticate user, set session[:user_id], and redirect

Part III: Logging Out

  1. add logout link
  2. add logout route
  3. add destroy action in SessionsController
  4. clear the session and redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment