Building a Games Guide

Basic Idea

Requirements and Goals

  1. Use of the MVC pattern
  2. Use of Active Record ORM
  3. Have user accounts, where a user can sign up and login/out
  4. Have appropriate has_many and belongs_to relationships

Object Definitions

Object Relationships

Visually Planning

Initial ERD
User create (CR in CRUD):
User show
User Update/Delete: (U, D in CRUD)
User index
Game create (CR in CRUD):
Game show, Tag create and Comment create
Game Update/Delete: (U, D in CRUD) and Tag create
Game index
Comment Update/Delete: (U, D in CRUD)
Type show
Type index
Tag show

Hello Sinatra

Model Building

User table
User relationships
Type table
Type relationships
Games table
Game Relationships
GameTag table
GameTag relationships
Tag table
Tag relationships
Comment table
Comment relationships

Test Objects and Relationships

>> will = User.new
>> will.username = “willcarter”
>> will.email = “will@email.com”
>> will.password = “password”
>> will.save

Implementing CRUD

  1. If an object is to be created, the controller routes to a view called new.erb, which contains a form with fields necessary to create a new object. The user fills out the form, which is POSTed back to the controller at a route that creates the object in the database.
  2. For updating, the controller routes to an object edit form in the edit.erb view. The user updates the object attributes in the edit.erb form, and that information is PATCHed back to the controller, where the object is updated in the database.
  3. For deleting an object, the delete action is initiated in edit.erb and sent to the controller via a DELETE method. Then the object is deleted in the database.
Create/Edit a User
Delete a user
Signing up a new user
Logging in with first user
willcarter successfully logs in!
authenticate method, provided by bcrypt
password is encrypted in the database (password_digest)

Adding forms and making adjustments

dependent: destroy
dependent object destruction
join table now has user_id
remove user_id from tags
User/Tag many-to-many setup
Updated ERD based on the change

Completing the Views

Game index
Game show
Game update
Tag index
All the views completed for each of the objects, shown in Visual Studio Code

Validations

User validations
Using valid? to check user before saving
checking for user object errors, displaying them
checking for user object errors, displaying them
Validation errors displayed in the view
Validation errors displayed in the view

Responsive Design

Games Guide home
Family Games
Responsive testing
Responsive phone view

Conclusion

Overview of the Games Guide

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MicroK8s Kubernetes Single Node Cluster

Make your Github profile look great!

Take some Git magic potion

Top iOS App Development Trends to Watch in 2022?

In this article, we will talk about the Cronos network, as one of the most advanced IBC projects.

10 Mini Python Projects That You Should Try in 2022

Python: Getting Started with Lists

Calculadora Em Dev C Download For Mac

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Will Carter

Will Carter

More from Medium

CS371p Spring 2022 Week 4/11–4/17: Blog #12

PlayerOne the best Blockchain Project

CS371p Spring 2022: Randall Crawford Blog 9

CS371p Spring 2022: Christopher Carrasco — Week 11