This exercise will force you to work in new branches for each feature. One a feature is complete merge it back into master by
- committing your changes
- checking out master
- running
git merge other_branch
We used scaffold_sinatra to create a new application called mister_user_app
Fork my mister_user_app and clone down a copy.
Create a Sequel migration file in db/migrations to create a users table
A users table should have the following attributes and datatypes
- email (string)
- name (string)
- gender (string)
- picture (string)
- dob (integer)
- phone (string)
- location (string)
- password (string)
Create the corresponding Sequel::Model for User
Create a rake task db:seed_random_users
When invoked it should:
- load up the environment
- Do an HTTParty request to
http://api.randomuser.me/for a random user - Save 10 users to the database
- print out that 10 users were created
Create a module called RandomUser with a module method called fetch
that performs the HTTParty request and returns the random user data.
Store your module in a /lib folder
Update config/boot.rb to load up all the files inside lib
Update your Rakefile to use RandomUser.fetch
In your User model create predicate methods for:
male?female?mr?ms?miss?mrs?adult?over 18boomer?born between 1946 and 1964teen?if between 13 and 18tween?between 11 and 12child?between 4 and 10toddler?between 1 and 3baby?between 0 and 1
Create a new migration to update the users table that
- removes the
passwordcolumn and adds apassword_digestcolumn
Implement a secure password using the sequel_secure_password gem
Create a "Sign up!" link on / that goes to /signup
/signup should display a form to enter
- password
- password_confirmation
post to /users and save the user to your database then redirect to "/"
Create a "Login" link on '/' that goes to '/session/new'
'/session/new' should display a form to enter
- password
post to '/session' if the user is properly authenticated, store their id in session and redirect to their show page.
If a user enters the wrong password information redirect them back to the login page and use rack-flash to display a message that they entered the wrong information.
