My Pokemon Team Generator

Marlon Moreno
4 min readFeb 24, 2021

--

So for my second Flatiron project, I needed to create an MVC(Model View Controller), CRUD(Create, Read, Update, Delete) app. For this project I decided to do something similar to my previous project. Basically, a user would be able to Sign up/Login and from there be able to create, view, edit, and delete a team of Pokemon.

I first started off by making my db tables, being a pokemons, teams, users, and pokemonteams table.

Then from there I made my made my models with their necessary associations, you can see below, the ones I did for my User model.

And one of the more the more interesting parts of my project was when I incorporated the API from my previous project into this one. What I ended up doing is parsing a random URL from the Pokemon API, which would become a users Pokemon, and from there I would would set the necessary values equal to their corresponding keys in the info hash, and then create a new Pokemon object with that hash.

Once I had I had all of my Models set up I moved on to my Views and Controllers. Besides the application_controller(which includes some helper methods) I made a controller for Pokemon, sessions, users, and teams, with the more complex one being the teams_controller.

There I set routes that would let you see your teams, and also make a new team and post it.

And I also made routes that let you view, edit and delete a specific team.

But to be honest, I probably had the hardest time with making my Views files.

For starters, I was having a really hard time learning how to incorporate Bootstrap, but after watching a some hour long videos, I was able to make it work.

And just to give one example of my Views folders, I will bring up the one I struggled the most with, the edit.erb file for teams. Before I even started I knew I wanted to make it so that the page would update every time a Pokemon was created or deleted. So at first I really just ended up complicating things for myself by making buttons that incorporated javascript. Later, after getting some advice from a friend I realized I could just use forms that when submitted would just take you to a specific controller that would just redirect to the same page. So this is what one of the forms looked like, this one specifically would take you to the Pokemon controller when the button was pressed..

And then the controller would make a new Pokemon which would be saved into a team set of pokemon, and from there take you back to the edit form.

This specific views file was definitely the part of the entire project I struggled with the most.

And to be honest, I felt the exact same way I felt when I was making my first project, I was really nervous. But thankfully with the help of some friends and my co-hort lead, I was able to make something that I am really proud of.

--

--