ColdFusion to Ruby on Rails: Part II

Books. I like ’em.

So that’s where I started my conversion. I remember when Ben Forta WACKed m- let’s rephrase. I remember when I got Ben Forta’s WACK book. Web Application Construction Kit, that is. It was amazing. Not perfect, but it was the singular reference I needed almost every time. So I sought out the same for Rails 5.

Uh oh. No WACK for that. That’s cool, may be the titles are just misleading. Except wait: here’s Ruby on Rails 5.0 for Autodidacts! I’m an autodidact! I want Rails 5! Let’s do this.

And that’s when it started. I came for Carl Sagan, and I got David Blaine.

So then I read Ruby on Rails Tutorial: Learn Web Development with Rails (Addison-Wesley Professional Ruby Series). Then Ruby: Learn Ruby in 24 Hours or Less. Then Learn Ruby On Rails For Web Development. Then Learn Ruby on Rails: Book One (I thought going back to basics would help). Then Rails Crash Course. Then Learning Rails (out of date!).

All of these books are great, especially the Michael Hartl and Anthony Lewis volumes (just like everyone said). But they all have a pretty big shortcoming, for me. They’re too magic.

For the absolute beginners, that’s cool. Get them making something that works as quickly as possible. But that doesn’t work for me.

I’ve been building applications for 10 years, and while MVC is new to me, I need more that “if you type this, web pages happen.” I know there’s some debate that Rails is “too magic” in practice, but I disagree. I think it’s “too magic” in explanation.

For me, the Rails magic is exactly the same as my Vim customization. I do snippets and custom scripted commands and fuzzy matching and all kinds of stuff that would take hours to explain to someone. But I know how it works even if I don’t think about how it works except when it breaks.

So when I’m told that

posts get '/entries' => 'Posts#show'

makes a web page load, I need to know why. I need to know that it’s a named route so that it can be referenced for link_to tags, and that Rails use the HTTP method to filter the answer, then looks for a controller with the same name and a method with the same name, and if you want it not to, then you do it another way, etc. There’s a lot of “hey, just copy this into your routes.rb, and you’re good!

That’s awesome if I’m building your app. I want to build mine, so I really want to see all the possible permutations (within reason) not the singular way it works in this instance.

So yeah. All the books were basically cookbooks. Some had a bit more details, others had some webdev philosophy, but none of them really just explained the magic. That is, until I found Learning Rails 5: Rails from the Outside In. Then things picked up.

Finally, someone was reiterating that naming conventions are a large part of Rails. Finally, someone routinely said “this is how we did it, but you might do it this other way for these reasons.” We were still building a single app (sigh), but we were exploring more.

The best part? After that, I could go back to all those other books. I could look at their code and I now understand every line. I can now think about something I want to do and imagine the code in my head (probably with several syntax errors). But I finally get what ideas go in which files and folders. That’s huge. Because now, when I start actually writing Rails code, I won’t need to look up anything but syntax or gem documentation.

Now, I can also read some Rails 4 books. The risk of confusion is far less, even with the relatively minor differences in basic concepts between 4 and 5.

And now, when I watch tutorial videos, I’m finding issues! I watched someone use a CDN for bootstrap. Why didn’t he download and use the asset pipeline? That’s what it’s there for! Why is this other guy deliberately undoing the basic ApplicationController hierarchy and routing? He could accomplish the same with simple model relationships and custom routing, and then anyone else looking at his code would be less confused. That’s all pretty exciting stuff, because it means Rails is becoming part of my thought patterns.

I mean, I’m still really slow to parse things, and I can still get confused or forget basic stuff. I can’t go to the Olympics, but I can throw the javelin and keep it on the field, at least.

What’s next? Well, I want to get my hands on Agile Web Development with Rails 5. That’s a very popular book, and I hope that I’ll be able to skip large portions of it, and drill down where I need a new perspective. I will say that it’s been very helpful to have different people explain the same concept or process. If you like to learn by book, I highly recommend diversifying your library.

And of course, someone has mentioned ColdBox MVC and CommandBox CLI for ColdFusion. So I’ll be checking those out both as a potential reformation of how I develop ColdFusion, and preparing my brain to think in MVC more robustly before I make the full switch. So Part III will be my first attempts with CodeAcademy/Udemy or some such, and maybe even starting my own custom app.

There are no comments