Ruby’s first day

So, I had my first day hand-in-hand with Instant Rails today. Following the tutorial I managed to get all the way with only a few minor hickups (read: leaving for a few hours, coming back and starting from further down the page and missing a few important lines), which I think is pretty good.

Sure, its not rocket science when you are following on with the tutorial, but it’s a pleasant feeling when the ideas begin to stick. Anyway, here’s what I know, -which is nothing new to
others doing the tutorial:

1. The model
I guess you could call it a data binding. Its a file that connects a table from the project database, to a controller.

2. The view
This is where the HTML markup gets stored. It *does* have some Ruby logic in there, but only for display purposes.

3. The controller
I guess this is like the brains of the operation. It’s the logic.

Tie them all together and you have something like : Bob goes to www.site.com/products. Ruby goes and looks for a controller called “products_controller”, which has in it an “index” definition. This definition attempts to retrieve data via the model “products” and then Bob sees the results of the query because of the template called “index”. A little confusing at first, but then I got the hang of it. And then I realised i’d seen something like this before…

I realised that I’d used a very similar concept to MVC when designing and implementing utsdesign. I had decided then to separate all the logic into one set of includes, templates into another, and then control how dynamic data gets fiddled with in one central location. The first big difference to that approach and Ruby is that in Ruby you don’t really have “pages” like index.php. Instead you have those def calls in the controller. Which is a much neater way of doing things.

Anyway, that’s day one of my learning. A good start.

  • http://rant.blackapache.net OJ

    Nice Danny boy. MVCs are pretty neato when dealing with any form of code, especially that which is displayed via the web. The definition of a model in a true MVC sense is “the data and its structure” rather than “data binding”. This may be slightly different in the case of Ruby so I’m not saying that you’re wrong :) The process of achieving a view of the model is the data binding part – but that doesn’t technically have anything to do with the model as the model doesn’t care about how it’s viewed. All it cares about is itself!

    Nice post though. Looking forward to more Ruby thoughts as it’s something I’ll be dabbling with more and more as time goes on.

    Cheers :D

  • dan

    See, now I was waiting for someone to set me straight! All these little bits of info come together in the ned and round out the Ruby picture, so thanks :)
    Hopefully I’ll get some more done in the next few weeks – even better, if my ISP had Ruby installed, I could show off some coolness to all!!!

  • http://rant.blackapache.net OJ

    Dude, I’m looking to change hosts as I mentioned on the tele-bone last time we spoke. I think we’ll be on a new server by the end of the month at the latest.

    When we are, I’ll be sure we all have Ruby access :)

  • dan

    :D Ur a champion among men!