My Imagine Pad Rails Project

Welcome Back! To another project created by… me, of course. This time it is for the FlatIron Phase 3 Ruby On Rails project. My first two projects were on books and reviewing books, but with this project, I felt it kind of repetitive to base it off again on books, but at the same time I wanted to relate my project to it. I’ve decided to create a project that allowed Users to create their own concepts for a story/idea, but to limit the User to just books, I’ve added a Media Type model, so that their concept can be for books, magazines, cinema, radio, etc. This idea came to me, by waking up one day, and scrolling through Reddit, and seeing people write novel ideas and other users pitching in their own ideas to that novel. My project is called Imagine Pad(totally did not google free names online).


Imagine Pad consists of 4 models: User, Concept, Genre, and Media Type. User has many concepts, has many genres & media types through concepts. Concept belongs to a user, genre, and media type. Genre has many concepts, has many users & media types through concepts. Media Type has many concepts, has many users & genres through concepts

Once I’ve planned what my project was going to be about and what needed to be done, it was time to start. This project is a lot similar to waht we did for Sinatra project in what the web app needed to do, but the difference is that we had to use Ruby on Rails which is a lot more intuitive than Sinatra, and we’re able to do a lot more with. This includes using partials, helpers, before action, private methods, strong params, routes/custom routes/nested routes, nested forms, scope methods, and omniauth. Yeah, this is a lot to learn and implement, but once you get more acquainted with these new concepts(lol), the more you see how it makes your life a lot easier and follow a very important principle D.R.Y (Don’t Repeat Yourself).


The ‘Don’t Repeat Yourself’ principle is exactly what it sounds like. Its focus is to reduce repetition within your code. If you have a repeat code or logic in your program, and they realize that you’ve made a mistake or need to change something, then you would have go to every instance where you implemented that code to fix, and you still might miss some. Would it not be easier if the code or logic was in one place, so you will only have to fix/change in that place without breaking your program. This is where partials, helpers, and private methods come in handy. Private methods are methods that belongs in your controller to help take out repeat code. The most common example you will see is when using strong params.

As you can see if we used ‘params.require…’ in multiple actions, it will stray away from the D.R.Y principle and make your code look ugly.

Next are partials and helpers which both take out repeat code and logic from your views, so what's the difference. Helpers are meant for smaller use logic with the views while Partial is for larger chunks of code and logic. A great example of when to render a partial is when you have a form and that same form can be used in a new page and edit page. So, instead of putting the same form twice, we put it in a partial that starts with a ‘_’ to let it be known that it is a partial and not an actual page.

Another great example of when to use a partial is to list any error. This will live in the layout folder, but wait… this partial is supposed to be used on pages with different variables. This is when we render a partial that can set local and instant variables. You set the variable to the variable you want and the code in the partial will use that variable which will represent the original.


This project also requires a user to be able to sign in from another service. Omniauth is a gem that allows us to do just that. I decided to do Facebook since that is something I’ve already in a previous lab, so I figured it would be easy which it was and at the same time was not. The gems I had to implement were ‘omniauth’, ‘omniauth-facebook’, and ‘omniauth’. Then I had to give Omniauth my apps’ OAuth credentials that would go in its own omniauth.rb file that lives in ‘config/initializers. The OAuth credentials need to be hidden in an env file that comes from the dotenv gem. With Facebook, you’ll have got to the Facebook Developers app and follow the instructions to get the credentials necessary. Lastly is to route the OAuth flow into our application by creating a route and an action in the controller that sets the attributes. All this and I still do not understand completely how everything works.

Biggest Obstacle

My biggest obstacle did not come from working on the project(well maybe setting up the Omniauth is a runner-up). My biggest obstacle came from life in general, when something happens to hinder your mind and soul from completing any objectives and goals. Nothing has happened to me, but just questioning myself and having to find those answers really was big hit upon the two weeks of creating the project because although I was able to complete the project and meet the requirements, I did not give it my all and that was disappointing. This is life in general, you have your ups and downs, you fall down and get back up, but the important thing is to remember why you’re doing it that makes you get back up and build the discipline of working through troubled times.

Final Thoughts

This project was definitely a big one and it took a lot of elbow grease to get it done. It was definitely overwhelming at first and throughout the project, but what I found made it easy, is to just break it down into small pieces and get them in, and eventually before you know it all those small pieces will be your grand design. I can honestly say though that I thoroughly enjoyed this project as well as the previous ones. It’s time for the next phase of this course.