Skip to Content
Ruby on Rails® for Microsoft Developers
book

Ruby on Rails® for Microsoft Developers

by Antonio Cangiano
April 2009
Intermediate to advanced content levelIntermediate to advanced
479 pages
12h 55m
English
Wrox
Content preview from Ruby on Rails® for Microsoft Developers

1.6. Whetting Your Appetite

A "Getting Started" chapter would not be complete without an example to show you how quickly applications can be prototyped thanks to Rails. The aim of this section is truly to "whet your appetite" as opposed to provide extensive explanations of each step. In Chapter 5, after covering the Ruby language in Chapters 3 and 4, you'll create a more complex Web application and everything will be explained in detail. Here I'm going to provide you with a sneak preview. After all, Rails became so popular thanks also to its ability to create entire applications with just a few commands.

Begin by creating a Rails project that can hold your friends' addresses. From within a directory of your choice (for example, c:\projects), use the command prompt to run the following commands:

rails addressbook
cd addressbook

This generates an addressbook directory that contains the skeleton of your Rails application, and the second instruction makes it the current directory in your prompt.

This being Rails, you'll use a table within a database to store the data. This table will need fields like the person's name, address, phone number, and perhaps email and blog/site URL.

You can specify those fields and their data types thanks to the so-called scaffold generator, as follows:

ruby script/generate scaffold person name:string address:string phone:string
 email:string blog:string

This will generate a model, controller, and a series of view templates required to provide you with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Michael Hartl

Publisher Resources

ISBN: 9780470374955Purchase book