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.