RSS 2.0
 Thursday, June 22, 2006

I have had the idea for a “web 2.0” application for some time, and playing with Ruby on Rails has spurred me to try a pre-alpha development of it. Make it pre-pre-alpha.

So, first step - a basic database diagram. I decided to use SQL Server 2000 as my database (not MySQL which is traditional in the open source world) because that is what I am used to. I like Enterprise manager, and I work quickly inside it. I found playing with MySQL from the command line too limiting.

I have created 4 tables to start:

First you have categories. Categories contain a number of goals. Goals contain a number of paths. And paths contain a number of steps. This is by no means complete or final, but it's a start.

Now, lets see if I can get a series of web pages set up to manage these four tables and their nested relationships.

By the way, there is a pretty good rails tutorial at O'Reilly OnLamp.

Once I have the database created, and have configured Rails to use SQL Server, I then use ruby to generate the model and component objects for these classes.

What is a model? A model is a data-tier object that represents a database table - it is a class. It provides the basic data-related create, delete, update, and find functionality.

What is a controller? A controller is an application-tier object that publishes a number of predefined (inherited) and custom methods and properties. It is also a class, but it is one level of abstraction above the database object.

Now I can generate the models and controllers separately. You can see what that looks like here and here. But I want Ruby to go that extra step further and generate all the starting code I need for my web app. You'll see what I mean in a second.

You know the old saying, “it's easier to edit than to create“, so I am going let Ruby create the basic HTML and classes needed for my application, and I will simply edit the pages according to the look and feel I want for the site. This pregenerated code is called “scaffolds”, and they are pretty cool. This will generate the models and controllers at the same time.

I will do this for all four of my database tables.

Finally, when I start the ruby web server (“ruby script/server”) and point my web browser to http://127.0.0.1:3000/categories I get:

Which is ugly as sin, but at least it's something to start editing. When I add a few sample categories it gets a bit better:

This is fun. Ruby on Rails is fun.

 

Thursday, June 22, 2006 10:34:47 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2] -
Demo Code | Ruby on Rails | Technology
Del.icio.us Digg Technorati Blinklist Furl reddit
Archive
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Scott Duffy
Sign In
Statistics
Total Posts: 464
This Year: 23
This Month: 1
This Week: 0
Comments: 73
Themes
Pick a theme:
All Content © 2008, Scott Duffy
DasBlog theme 'Business' created by Christoph De Baene (delarou)