I almost finished ORMs and ActiveRecord tonight but I have one more video lecture to watch. There were 4 tonight which totaled over 4 hours so even on 2.0x it took a lot of time. I’m deciding to be in bed before midnight rather than finish the review. Maybe I’ll just fall asleep to the sound of Avi’s voice playing the video cast to my TV…? Actually, nope, not doing that.
I’m still struggling with understanding databases and how they relate without seeing a visual. However, ActiveRecord is making it A LOT easier to piece together. It’s bringing the database back into Ruby. From my notes tonight:
The model that
has_manyis considered the parent. The model that
belongs_tois considered the child. If you tell the child that it belongs to the parent, the parent won’t know about that relationship. If you tell the parent that a certain child object has been added to its collection, both the parent and the child will know about the association.
This is just good to know. It’s pretty self-explanatory I think. A really cool thing that Avi utilized in one of his lectures is Rails Erd. It takes the database tables and graphically shows how they are connected in a Rails app. I couldn’t get it to work as I’m not using Rails yet and I didn’t want to spend too much time messing with it but I’m definitely going to use it. If you’re interested it’s a pretty quick install and usage process:
brew install graphviz
gem "rails-erd" to your Gemfile.
bundle install rake erd open erd.pdf
An example pulled directly from the repo:
According to my dashboard, I’m at 53 lessons for the week so I hit my goal of 49 with a day to spare! I’m super happy about this (although, sometimes I don’t trust the numbers on my dashboard…) and don’t plan on stopping now. We have an engagement (marriage, wedding, I can’t remember) part tomorrow at a winery so hopefully, I can still get a decent amount of coding in. Although, my shaggy mop is going to get a trim in the morning before we go so I might lose most of the day/afternoon/evening. I guess a social event a couple times a month helps to keep the sanity.
Time spent today: 7:08
Time spent total: 145:03
Lessons completed today: 9
Lessons completed total: 339