School Archives
Off to See the Wizard
Or rather I guess I AM the Wizard, because today was metaprogramming. Now I know what makes ActiveRecord so magical. Ruby makes self-referential code (relatively) easy, so we were able to dive in and make our own ActiveRecord Lite today. It was a little tough going at first, not just because meta stuff can seem kinda abstract–after a week of mostly SQL, it took some time to remember how Ruby worked…But it came back soon, haha. Saw my old friend instance_variable_get
again, along with instance_variable_set
, define_method
, and send
.
AR = Advanced Reality?
(Yeah I’m going to keep going with these)
So more ActiveRecord today! Actually now I think I kinda got the hang of it: all I had to do was blindly accept ActiveRecord into my heart and believe, and so it was! Also it helped that I was finally enlightened to the .select/.joins/.group/what-have-you SQL-like methods in last night’s readings. I’m just all around enlightened now really.
I Had NO Idea
Yesterday I said “ActiveRecord seems much more built out.” Talk about understatement of the CENTURY. And I thought Ruby was high level. HA! Basically, in ActiveRecord, if you can dream it, you can do it. (Sidenote: I always attributed that to Blades of Glory but apparently it’s from Walt Disney?)