Week 9 "Authentic" Assignment

This week you’re going to create a web app that users can sign in to.

Code quality – I’ll be watching for these...

  • Don’t use return, true or false unless you need to.
  • Indent your code with two spaces. Make sure your indenting is appropriate. Don't have more than one blank line between blocks of code. (Get in touch if you need help configuring your text editor. This should be mostly automatic.)
  • Commit in git regularly (after completing each feature is usually good) with informative commit messages.
  • Add validations where they would be needed.
  • Use before_action to cut down on duplicate code in controllers.

Your assignment

  • Create a Pages controller with a index method and view
    • This should be your root route
    • Put whatever you want on it – maybe a picture of a cute animal?
  • Allow users to sign up and sign in to your web app
    • users should have name, email, password, admin (boolean field), and last_signed_in_at (datetime)
    • when they create an account they should automatically be signed
    • after successful sign in, record the current time in the user's last_signed_in_at field and redirect to the homepage (you can get the current time in Ruby with Time.now)
    • if there is a sign in error (e.g. wrong password), show an error message using the flash and let them try to sign in again
  • Put some navigation links in your layouts/application.html.erb
    • When a user is signed in, show a sign out link and a link to edit their profile
    • When a user is not signed in, show a sign in link
    • When an admin user is signed in in, show a link to the Users#index page
  • Let users change their name, email or password once they are signed in (don't let anyone else change their info!)
  • Create a Users#index page that lists each user account
    • Only let admin users see this page
    • Each user should have a "delete" link
    • Only let admins delete users (enforce this in the controller)

Add some styles

Add some styling. You can write it by hand or use something from a CSS framework.

Submit your work

When you are done, push your work to Github. Then email me a link to your repository on Github: alex@dunae.ca