top of page
  • Writer's pictureRafael Lopez

Analytics Rating App with Rails

I'm super excited to continue my software engineering journey for digital analytics work thanks to my scholarship from Facebook and the Flatiron School. I just built a new web application called Analytics Rating App, a complete Ruby on Rails application that manages related data through complex forms and RESTful routes.


Homepage of the web application built with Rails.
Homepage of the web application.

I decided to work on this project because I am a firm believer in constant professional development. I need to mention that due to the rapid digital pace we are living, I live in a forever state of fear thinking I don't want to and won't be left behind professionally so I'm constantly taking courses everywhere (Udemy, Coursera, CXL Institute, etc you name it), I attend workshops, read what the pros are Tweeting, Slacking, reading, posting on LinkedIn, etc.


Because of the previous, a few years ago I realized I was doing too much and needed to organize myself so I did what analysts do best...created a spreadsheet to organize my data, in this case, my data was the courses I had taken plus the ones I wanted to take. To this day I still reference that sheet that has helped me so much in my technical journey but today I wanted to take it to the next level creating something similar but expanding on the idea by adding courses and ratings to them in a web application. This is exactly what I did with the Analytics Rating App.


Before I start explaining how I built the app I'm sharing below a tab example from the spreadsheet I mentioned before with info from the man Trevor Fox, who shared so much knowledge and helped me organize my way through technical analytics, marketing and programming after a mega cold DM I sent him through LinkedIn in December of 2017.


Some of my programming roadmap resources.
Some of my programming roadmap resources.

Now, let's talk about the actual app. What is it, how did I do it, how long it took me, I'll share brief details about all of it. First of, the Analytics Rating App is based on the Ruby on Rails framework and is using the MVC framework as well. MVC stands for Model, Views and Controllers which in dev are like when you go to a restaurant and have servers attending you and food being prepared in a cool looking dish by a chef.


The servers are in our case the Controllers, the ones responsible for "taking orders". The go-between for models and views. The controller relays data from the browser to the application, and from the application to the browser. The Models are the 'logic' of a web application. This is where data is manipulated and/or saved. The Models are basically the cooks in our restaurant analogy. They process the orders the Controllers send to them.


Then we have the Views which are the 'front-end', user-facing part of a web application - this is the only part of the app that the user interacts with directly. Views generally consist of HTML, CSS, and Javascript so continuing our restaurant analogy Views are the actual food presentation.


Touching again on the Models, the brains of applications, in them is where developers can add for example associations among classes and data validations. In my case, since we have classes or object-oriented programming 'objects' for students, courses and ratings, I created has_many, belongs_to, and has_many :through associations.


In terms of validations, if a student for example would like to sign up and create a profile he/she would need to include a name, last name and password with a specific characters length, presence needs to be true for the three of them, and passwords need to be unique, among a few other similar validations. If any of the previous criteria is not met, the user would receive a validation error and the 'student' would not be saved to the database.



Example of a form validation error.
Example of a form validation error.

Let's move on now to my database table and classes. Since I've been building an app where the only possible user actions are to create a mini profile, add courses, and rate those courses I had to create tables for courses, students and ratings. Each one of these have their own individual attributes that after being set I could query or use across my program. For example, a student has a first, last name and email, courses have a name and instructor and the ratings table have a rating. This last table tho is a little different than courses and students because it is what in dev you would call a 'join table' which means it is the one that can have communication across your other tables if you use ids and a has_many :through relation. This is in other words what is called a many-to-many relationship. In summary, I am able to make model associations for courses and students with the ratings table.



Join table to associate my models through foreign ids.
Join table to associate my models through foreign ids.

Lastly, I also added standard user authentication to my program, including signup, login, logout, and passwords. I used a gem called 'Omniauth' and did my very first user authentication login with a social channel using Facebook. It was pretty cool doing my research and implementing it so I intend to continue playing around with this method. Maybe I'll try Google and Github next! Other than that, one other thing I'd like to mention is that I learned about partials. Partials are awesome to clean your code so instead of having repetitive lines across views you can create a 'partial', dump the repetitive code there once and then you can replace the repetitive code from everywhere else with a sweet short line of Ruby code embedded in your html views.


That's it. It was tough, took me forever, asked for a lot of help but I did learned a ton. I'm excited to move on now from Rails (for a bit) to focus on my favorite...JS! Stay tuned for my next project and check this one out on my Github. Clone it, play around with it and let me know your thoughts.



Form to add course ratings.
Form to add course ratings.

10 views

Comments


bottom of page