August 2015 Archives
DiscoverIT
To continue with my series of really terribly named Rail projects, we made a RedditLite spinoff called DiscoverIt. (Can you believe it actually took a thesaurus to come up with that awful name?) The project itself was relatively straightforward until the end, but afforded good practice with setting up a shell of a site, complete with user sessions, ability to submit/edit/remove content, etc. The “cross-posting” feature was a cool new thing in that it introduced us to yet another amazing ActiveRecord feature, the ability to not only auto-populate foreign keys, but even create rows in many-to-many tables, based purely on associations. Once again, I didn’t really think it would work, but why do I ever doubt ActiveRecord?
More details…CatRecords =^v^=
For all your feline listening needs! Actually I should have done that instead of lamely choosing real bands and songs. Then I probably would have spent most of my day coming up with horribly punny and/or childish cat songs instead of trying to get a dynamically generated site navigation bar up, which was how my day was actually spent.
More details…
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
.