Accelerated Application Development with AppTrain
on Ruby on Rails
This article contains your
personalized fortune. I'm getting a reading on your future right
now...
get ready for your life to change ... You are going to love
AppTrain. After spending 20 minutes and creating
a few simple web
pages that store their information in a database, you'll be amazed
and want to know more.
Eventually you'll realize
that AppTrain is just a simple Web front end for creating
applications that run on
the Rails framework. You'll then seek a
relationship on a deeper level. Then , you're going to love Rails.
Rails is a
brilliant framework that will give you the opportunity to
develop well structured web applications in the coolest
and the
hottest language around. Ruby. And of course, you'll love Ruby.
Step 1: Designing the Petstore App
Let's
start with some concepts that represent items for sale in a petstore.
The diagram below shows three
distinct concepts in the petstore;
category, product, and
item.
This diagram captures what data we need to collect for our petstore
app. In software design,
we call
concepts that will be represented by software classes.
So this diagram is a class diagram. Each box in the diagram
represents a separate class. The top portion of the box is the class
name. The bottom portion contains attributes that
each item
in that class will contain.
Petstore Class Diagram
| ||
|
1 | | \/ * | ||
| ||
|
1 | | \/ * | ||
| ||
If
you've worked with databases before, You'll be happy to know that
Rails maps each class to a table,
and each attribute in that class is
a column in that table.
Just to keep your head in the game, AppTrain maps classes to Forms, and attributes to fields in that form.
Also
notice the arrows between classes . These signify relationships
between the classes. So from
the diagram,
we know that a Category has many Products, and a Product
belongs to a category.
|
AppTrain |
Rails |
Database |
Petstore eg. |
|---|---|---|---|
|
form |
class |
table |
category |
|
field |
attribute |
column |
name |
|
combo-box |
relationship |
foreign_key |
Product belongs to a category |
Step 2: Creating an A-Train App
All
right, it's 2006 already. No need for any software installation,
1 The network
is the computer right?
Take a trip in you browser to http://www.apptrain.com/app

Enter a name for you new App
in the lonely text area. Your own name is fine. For this tutorial
I'm using 'petstore' . Then click 'New App'
Nice work! You've created a space for your App. Now it's time to create a few Forms.

a) In the Text Field labeled 'name' type category.
b) Now go down to the data fields section, and type name in the 'name' field.
c) Then click 'Create'.

Awesome, Now click 'New Form' and name this form product.
In
addition to the name field that we added to category,
product also contains a
description field.
So click the '+' button, and type description in
the new 'name' field that appears. Then click the 'Type'
combo box
next to description that says 'text'. Change it to say 'multi-lined
text box'.
Now hold on a sec ... don't hit 'Create' just yet!
Step 3a: Adding a Relationship.
Hit the plus sign once more.
Then click the Type combo box again. Notice that it has 'Category'
as an option. Select that. This new form will now reference
'Category'.

Now you're ready, and your screen should look like the one above. Hit 'Create'.
.

a) Click on the word 'category'
The white screen means that you've left AppTrain, and are now viewing your new Form.

b) Click 'New Category'.
c) In the name field enter something like 'Dogs', and hit 'create'
Click 'New Category' again and add something like 'Fish'
d)
Now hit the back button a few times, until you're back on the
blue “Editing petstore app”
screen, and click 'product', then new product.
Notice the combo-box at the botom of the screen. It is automatically
populated with data
we entered in the category form.
e) Enter a product like, 'Dog food', or 'Ceramic Castle' and assign it to a Category.

Notice how selecting different datatypes on the 'new form' screen changes the way data is entered on the form?
Lets look at the Item class:
|
Item |
|---|
|
name: text item code: whole number description: multi-lined text price: decimal number cost: decimal number available_on: Date image: File Upload |
Click the back button a few
times (sorry about all that but this is only an Alpha release!) and
get back to the pale blue AppTrain screen. It should say “Editing
petstore app” at the top.
a) Click 'New Form' and enter Item as the name.
b) Add datafields and make sure their 'type' corresponds to the types on the class above.
c) When your screen looks something like the one on the next page, hit 'Create'

The resulting Form should look something like this:

In almost no time and with
absolutely no code, you've created an administrative application for
your online petstore.

Welcome to the world of Agile development: http://agilemanifesto.org.
You'll find that Accelerated
development with tools like Rails and AppTrain. leads to much
greater collaboration with customers, which results in better
software.
AppTrain only scratches the
surface of The Rails Framework. I highly recommend a copy of
“Agile
Web Development with Rails” to get rolling.
http://www.pragmaticprogrammer.com/titles/rails/index.html
And to get a handle on the Ruby language, there's the PickAxe, aka. “Programming Ruby”;
http://www.pragmaticprogrammer.com/titles/ruby/index.html
I know that these are both
from the same publisher, but The Pragmatic Programmers have been
instrumental in making programming fun again for lots of folks,
including myself.
Well, if you made it this
far, back to your fortune.. The future looks bright! Welcome aboard
AppTrain.
1 For on-site development, get your own copy of AppTrain running: http://rubyforge.org/docman/view.php/1056/240/quickstart.html