A spicy meatball.

A brief soliloquy on RESTful routes and resource objects within the Rails framework:

Abstraction is not generally perceived as a quantifiable characteristic.

But it is.

And it is a principle of understanding the codified language. Fundamentally, abstraction is what allows us to write in a way that communicates with machines. Code can be overwhelming and disorienting but all we are doing is tracing ideas up and down levels of abstraction. I understand that this declaration is being stated rather casually but the first time I heard someone say “2 levels of abstraction” I almost fell out of my seat.

Abstraction is well, a rather abstract idea. It can quickly get messy. If you’re writing code to tell the machine to keep track of your idea of a ‘Duck’ so that you can simultaneously declare a ‘Quack and eventually stitch em together, things get sloppy and complex pretty quick. Frameworks and libraries wrap, generate, and handle abstractions so that we don’t have to.

The catch is that in order to harness a framework as a tool, you need to understand what its obfuscating. Lets examine one nugget of abstraction the Rails Framework handles for us:

resource :your_thing

RESTful routing in rails is a method of declaring multiple paths for information to travel on within your application by creating a resource. RESTful routing is a combination of a URL and a VERB. By declaring ‘resources’ within a web application, your new resource automatically inherits routes and methods for creating a CRUD workflow . This is one of those things that you need to say out loud over and over till it makes sense. I struggled with it all day until I stumbled across the word “POLYMORPHISM” — the concept of occuring in several different forms. Your resource object creates the URL that the browser will go tell AND the method of getting there.

rake routes

All this heavy duty conceptualization of abstraction and the migration of info in the digiverse can get disorienting. If and when you feel like you head is spinning while writing your app, hit up rake routes. Rake routes will show you all the routes you have declared in your application. It’s basically a map of the environment you are creating. That you can look at while you create it.

Over and out.


A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.