Specs:
- Use Sinatra to build the app My application controller inherits from 'Sinatra' which means that I can call methods like 'get "/" do'. These methods are generated by Sinatra and allow me to direct traffic on my web application. Sinatra is mounted on rack, which allows me to run rack-up or more practically shotgun to serve my application.
- Use ActiveRecord for storing information in a database My application database is sqlite3 but without ActiveRecord, it would be tedious to write queries. Active record generates a set of methods and make a tidy link between the database, the class, and the controller. I use Active Record methods in my controllers to instantiate new instance objects and to make queries of the database itself. I'm sure there is more functionality that I have not unpacked yet.
- Include more than one model class (e.g. User, Post, Category) I have only two classes. I wanted to keep things simple until I fully understood the concepts at hand. My two classes are 'users' and 'students.'
- Include at least one has_many relationship on your User model (e.g. User has_many Posts) In this web application, a user has many students.
- Include at least one belongs_to relationship on another model (e.g. Post belongs_to User) In this web application, a student belongs to a user.
- Include user accounts with unique login attribute (username or email) This was one of the more challenging requirements. At face value, creating a unique log-in was simple. The tricky part was keeping things separate and avoiding security holes.
- Ensure that the belongs_to resource has routes for Creating, Reading, Updating and Destroying
- Ensure that users can't modify content created by other users See comment above.
- Include user input validations
- BONUS - not required - Display validation failures to user with error message (example form URL e.g. /posts/new) When users log-in with incorrect passwords or try to sign-up with someone else's username, there is an error screen.
- Your README.md includes a short description, install instructions, a contributors guide and a link to the license for your code. I wrote this out, but unlike the previous project there is not as much that users need to do to clone this repo.
Confirm
- You have a large number of small Git commits
- Your commit messages are meaningful
- You made the changes in a commit that relate to the commit message
- You don't include changes in a commit that aren't related to the commit message
6 minute video tour of this app: https://youtu.be/a9zN86zyQlI
Blog: https://rlj0713.medium.com/how-do-databases-really-work-in-a-web-application-47f34770c065
30 minute coding think aloud: https://youtu.be/AtaPLO8An0c