Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Page 4 - Getting Started with Ruby on Rails
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
RUBY-ON-RAILS

Getting Started with Ruby on Rails
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2006-08-01

    Table of Contents:
  • Getting Started with Ruby on Rails
  • Understanding the Terminology of Ruby-on-Rails
  • A Ruby-on-Rails Application, Step by Step
  • Rails in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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` (

    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `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:

        development:

          adapter: mysql

          database: demo_development

          username: raj

          password:

          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:

    http://localhost:3001/demo/admin

    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.

       · RoR is the latest in the field of server-side frameworks. When compared to other...
     

    RUBY-ON-RAILS ARTICLES

    - Iterating and Incrementing Strings in Ruby
    - Comparing and Manipulating Strings in Ruby
    - Strings in Ruby
    - Ruby On Rails: Making Your First Dynamic Site
    - Ruby on Rails: Beginning Rails
    - Ruby: Modules, Mixins, Fixins, and Rails
    - Controlling Information Access with the Rail...
    - URLs, Filters and the Rails Action Controller
    - Flash and the Rails Action Controller
    - Rails Action Controller
    - Dropping and Sorting with AJAX and script.ac...
    - Drag and Drop with script.aculo.us and Rails
    - Introducing script.aculo.us
    - Ruby Classes and Objects
    - Ruby Loops






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT