w5d3 - route it out
Eric explained how the Internet works, and then we all went off to finish our Rails Lite. I really enjoyed wrapping up this project, and writing the Router/Route classes was amazing for understanding this aspect of Rails. I feel like routing is one of the more obscure concepts to grasp in the Rails framework. Rails makes it trivially easy to establish and draw the routes, such that a new developer can use them without understanding much aboutwhat they’re doing.
A route is simply an object, assigned to a specific controller class and associated HTTP method, that looks at the URL path from the request body and 1) pulls the route parameters out of the path, 2) triggers the appropriate action on the right controller, while also sending along the route parameters. The Router draws the routes and picks the right one for the job upon receiving an HTTP request. It then passes along the pertinent info from the request to the right Route.
One of the bonuses for the Rails Lite project was to implement Rails’s “flash” — an object where controllers can store data to be rendered by the views. Writing the Flash class was much easier once I remembered that the Flash would simply get garbage collected after the death of its initializing Controller. As Cristal Connors said in the 1995 Verhoeven masterpiece Showgirls, "There's always someone younger and hungrier coming down the stairs after you.” A new Flash rises each time a Controller is summoned, so if any Flash data needs to persist after a redirect, it’s the current Flash’s responsibility to write it to a cookie so that the next Flash can grab it.
flash.now[:messages] = ["Bye, darlin!"]
It’s hard to believe that the Rails curriculum is over. It feels like yesterday that Rails was this new, mysterious, intimidating thing. It’s now still new and mysterious, but far less intimidating — and much of the mystique has been lifted since we built our own versions of its most basic functions. There’s still so much to learn and master in Rails, but we’ve all got the basics down, as evinced by our cohort’s 100% pass rate on the assessment (hell yeah!).
Onward to Javascript. There is so much to do tonight. I should have known those bagels they gave us this morning came with strings attached.









