Youtube Idea Collector: Sinatra App Assessment

For my final project with Sinatra, I finally settled on building a simple app that will help me keep track of ideas! If you don't already know, one of my hobbies include creating beauty/lifestyle video content on Youtube. No I'm not a Youtube star in any way, but it's amazing to see its success, and the opportunities that have come along so far, from doing something that I find fun! And actually, I have this hobby to thank for introducing me to, and falling down the rabbit hole of, programming! Anyways, before I digress any further, because I don't keep track of paper notes very well, and because my memory is not exactly the best, I built the "Youtube Idea Collector" with Sinatra for my final project. I also still need to pair program Fwitter (aka "Fake" Twitter clone) for my second Sinatra final project, but again I want to wait for Alex to catch up so that we can pair program together in person. 

When I read the instructions for the first time, I think I was feeling a bit over-confident because I didn't think this final would be too bad, but I actually experienced quite a few trip ups along the way that literally had me stuck for days. My neighbors probably thought I had won the powerball from all the squeals of excitement they heard; nope, that was just me once I figured out what the problem was! You can view a demo of my app in action below, running through scenarios of signing up/logging in with secure passwords, creating/saving ideas, editing ideas, viewing all ideas, deleting ideas, error validations for bad information, and logging out.  Again, it's not very pretty because I didn't spend any time on styling it, however I'm happy to report that it works! 

My biggest problem was that I succumbed to the feelings of frustration instead of taking a step back to simply read my error messages. While pair programming with Avi yesterday, we re-emulated the error messages I'm sure I received, but was too blinded by frustration to pay attention to at the time. Ultimately, the problem was found in my database table; I had set up my join table incorrectly so my models didn't understand their relationship to each other. All I had to do was change "add_column :users" to "add_column :ideas "and bam... a working app! **Quick tip, the object that has the "belongs_to" association should ALWAYS have the foreign id in its table.**

Even though my solution was discovered before pair programming with Avi, I appreciated that he made me recreate the problem to become better at debugging error messages. I also appreciated his emphasis on using the console to play around with my app much more efficiently, and to be bold while doing so. Usually I take my time and think, acting as if I'm scared to press submit when really I need to just be fearless because pressing submit and guessing will always give me more information (aka clues) to actually solving the problem, even if that clue is a different error message! Sitting there just thinking about it won't. Initially I noticed I had a bug when I tested my app in the browser. I noticed that I could sign up, create/save ideas, and log out. However when I would sign up "as another person", using different credentials, the ideas I had previously created as the original user were still saved and visible to the new user. I had expected the new user to sign up and receive a clean slate, displaying no ideas because the new user hasn't created any yet! That means that the saved ideas did not know who it belonged to, which is exactly what my error message had read.

At one point I also ran into user authentication issues because I would be able to sign up successfully, but whenever I logged out and tried to log back in under those same sign up credentials, my page would throw an error saying that I must login or sign up to access the account, as if it had no idea who my user was; I expected my app to remember the users who have signed up. There was a problem with my sessions. To briefly note a couple more features, I also had to implement password encryption to secure user accounts which required me to reconfigure my database again and require a bcyrpt gem. Lastly, I needed to figure out validation features using error messages. For this I decided to use a gem called Sinatra Flash, snippets below: 

After all of that, I am humbled again to say the least! What I thought was going to be an easy final project actually proved to have some challenging bits, but again I am happy to report that we made it through! All I have to do now is submit it for a code review, which includes talking about my code and giving a walk through of my app. During this session we will also write tests, add new features and refactor my code. Next up is Rails, which I admittedly already snuck ahead in attempts to land my first developer job! No, I didn't get the job.