Home arrow Ruby-on-Rails arrow Page 4 - Getting Started with Ruby on Rails

Getting Started with Ruby on Rails

Enterprise applications are considered to be complex to design and develop. Technologies such as J2EE and .Net augment this generalization. But there are technologies and frameworks that beg to differ. Ruby is one of those technologies/languages and Ruby-on-Rails (also called RoR) is such a framework.

Author Info:
By: A.P.Rajshekhar
Rating: 5 stars5 stars5 stars5 stars5 stars / 20
August 01, 2006
  1. · Getting Started with Ruby on Rails
  2. · Understanding the Terminology of Ruby-on-Rails
  3. · A Ruby-on-Rails Application, Step by Step
  4. · Rails in the Real World

print this article

Getting Started with Ruby on Rails - Rails in the Real World
(Page 4 of 4 )

Since this is the first discussion of RoR, I won't be presenting a heavy duty example. However, the example to be presented will show the ease of development in RoR. So the example will be based on the Customer Order example I used in the section about MVC. The example will do the following:

1. Provide a form for entering the order details.

2. Provide a list view of all the orders placed.

3. Provide a form for modifying the data.

4. Provide a delete option for a specified order.

Before beginning the development, a database and table must be created because I will be using MySQL. There are certain conventions to be followed for the naming of the table and its fields: 

  • The table name should be plural, i.e. in my case the table name would be Orders.
  • The primary key should be of the type INT (for MySQL tables) and its auto increment attribute should be set to true.
  • Keeping the column names in lower case is recommended.

Keeping these points in mind, here is the table definition (the name of the table is demo_development): 

CREATE TABLE `orders` (

`product_name` VARCHAR( 20 ) NOT NULL ,
`cost` VARCHAR( 10 ) NOT NULL

) TYPE = innodb;

Now let's create the application. The name of the application is demo. So the command would be:

rails demo

Then change the config directory of the demo directory; the database.yml has to be changed in this way:


      adapter: mysql

      database: demo_development

      username: raj


      host: localhost

Next, to create a full-fledged database driven application, give the following command at the root directory of the application i.e. “demo”:

ruby script/generate scaffold order admin

Here the scaffold argument generates boilerplate code for all three components,  Model, View and Controller for the given table (Orders). The name of the controller is optional, though I have given it. This would create the ORM of the table name, the controller of the given name and the RHTMLs for the add, modify, delete and view functions. The name of the table has to be given in singular, otherwise the application would throw an exception when launched. To check what has been created, start the server, and give the following URL at the address bar:


That’s it. RoR creates all the boilerplate code required for CRUD operations. But there are various aspects that have to be understood before an actual application can be built. Starting with the next part, I would be discussing the Model, View and Controller components provided by Ruby-on-Rails. 

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials