Footy Project

I was working on a project that I called footy. Footy is a rails back-end, java script front project, while I was doing this project I especially learned a lot about serializer in rails , improved my java script, rails and custom css.

in the back-end, I have this drawing for project plan.I didn’t implement review and like relationship in java script , I will be doing them later on when I have more time.

So, in my project ,I implemented Match, player and Club relationships.

class Club < ApplicationRecord

has_many :players

has_many :matches, through: :players


class Player < ApplicationRecord

belongs_to :club

belongs_to :match


class Match < ApplicationRecord

has_many :players

has_many :clubs, through: :players


I also used fast Json api gem and serializers , as an example I’m am typing one of them

in player serializer file, I do this;

class PlayerSerializer

include FastJsonapi::ObjectSerializer

belongs_to :club, dependent: :destroy

belongs_to :match, dependent: :destroy

attributes :name, :number, :kind, :country, :age, :club_id, :match_id


By the way , we have dependent: :destroy , we want this in our serializer, if we don’t use it whenever we seed data using rails db:seed, in the database the table that we have for specific id will be empty, dependent: :destroy will delete this empty table and it reorganize the tables’s with new data id’s

so, it is good to use if you don’t want to see the data id with a lot numbers for example 300 or up numbers.Because we might wanna use rails db:seed more than once for testing purposes of our data.

Serialization, The process whereby an object or data structure is translated into a format suitable for transferral over a network, or storage (e.g. in an array buffer or file format).

In JavaScript, for example, you can serialize an object to a JSON string by calling the function JSON.stringify().

when we use serializer, Serializer makes data available to store it.

as you can see,serializer made one more level nested data called attirubes which in this case we can access to all info about a specific player.

I have seed.rb file which I used this web site

response = RestClient.get(url)

body = response.body

m_array = JSON.parse(body)

after converting data to json I seeded that data.

after setting up the back-end, I used vanilla js to set up front end. For html part I have 2 sections, one is where all the buttons stay other is where all the content to show users.

All the buttons have event listener with if else statements.

after using each if statement I have I make contentContainer.innerHTML =” ”

empty , when user clicks in other button , contentContainer will be filled only with that button’s event listener code.

Software Engineer

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