Activerecord
May 29, 2013
App Academy W3D3
First Day of ActiveRecord
Today is our first day with ActiveRecord, which is one of the core parts of Ruby on Rails. Learning about this well would contribute greatly in the future to my ability to be successful with RoR. It is something that we have been preparing for this entire week. And considering that a day at AA is like a week and a half in a more conventional school, that is a pretty long time. So basically, uhh no pressure huh?
The project today was to create the backend for a link shortener. This Link shortener (Ill call it LS from now on) is going to become a web app but for now we are just working with the models associated with that app. When I started out, I was greatly confused and struggled to get a grasp on the concept of the short URL and the long URL. I was not sure of what to do and luckily for me my partner was able to help me out greatly. Together, we talked out the structure of the program and how it would work.
Much of my confusion is because the truth is that I have no idea how link shorteners work. The way that I understood how a LS would operate was that it would somehow “remap” the original link. Thus then that original link would be basically “hiding” behind this new one. I suddenly felt a surge of panic because it seemed to involve so many other things like creating and mapping IP domains and what not. I felt that this was just way out of the norm from what we were doing before. However, my partner and I got a better grasp of what the project was about. You would be working on it from the command line, calling on methods on instances of the “long link” and the “short link” to alternatively shrink and expand it. Then you would use a gem called Launchy that would launch the site in a browser.
The eventual structure of the app would be to create a “long link object which would hold within itself the original link. Then it would hold “short link” objects that are generated from a long link. This is because some people may want to have a short link created from one URL. Why hold multiple versions of the same URL in your database if you have to? The next thing to do then would be to create user accounts that would then allow a user to create individual short links for their own personal use as well as give other statistics like “how many people have clicked on my link?”
Once the schema made sense to me, I was able to work together with my partner to successfully put the product together. We used a number of migrations in order to create the right data schema to use, adding and modifying specific columns to make for a better product.
3 Things I Learned:
1) Database migrations in Rails
2) Joining and making other SQL commands within Rails (though it is still something that I need to continue boning up on)
3) Belongs To and Has Many
Other Things I Think I Think:
Today I went with the shorts and this worked fine while I was outside but killed me when I was inside becaues the class room is more than a little drafty. Jesus I need leggings.
The market took a big dive today. I closed out of an individual position at a loss. Good companies at cheap prices are always a buy and I felt good about it. However, one should stick to the companies they are familiar with and are experienced in. Investing is about psychology. Do not invest in something you would not feel comfortable losing money on. Mastering the psychology is more important than mastering the financials.
Share