Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Page 2 - Ruby on Rails: Beginning 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  
Moblin 
JMSL Numerical Library 
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

Ruby on Rails: Beginning Rails
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-04-28

    Table of Contents:
  • Ruby on Rails: Beginning Rails
  • Controlling the Situation
  • A View...To a Kill (Duhn Duhn Dun!!!)
  • What Everything is For

  • 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


    Ruby on Rails: Beginning Rails - Controlling the Situation


    (Page 2 of 4 )

    To make an application work, you first need a controller. The controller is the evil overseer, the big boss, the big cheese, the head honcho, the imperial slave-driver. He is that guy that says "I think the benefits of slavery outweigh its drawbacks" and then makes you carry heavy boulders back and forth.

    To create this big galoot we use the following ruby command: ruby script/generate controller controllername. Below we will create a controller named Willis, in the hopes of later learning what the heck he was talking about:


    ruby script/generate controller Willis

    If you go to rubymyfirsttimeappcontrollers you will see a file name willis_controller.rb. This is the file you just created. You can open it to view the code if you like; just be sure not to change it.

    A Call to Action

    While having a controller is all fine and dandy, it's pretty worthless if it isn't issuing orders for its minions to follow. This is where Actions come in. Actions are what make your application do things. The following action will make the browser display some text. Here is how you add your action to the controller:

    Open the myfirsttime.rb controller file. It will show the text:


    class WillisController < ApplicationController
    end

    We are going to insert some text in-betwixt the first line and the end line:


    def whatyoutalkingbout

    end

    This creates a method called whatyoutalkingabout. Typically you would use something simpler, but I wanted to match the theme. And it's my article, so there. So now the file should read:


    class WillisController < ApplicationController

    def whatyoutalkingbout

    end

    end

    And lastly, in order to complete our beautiful web page, we must create a View.

    More Ruby-on-Rails Articles
    More By James Payne


       · Thanks for stopping by to read my article. In this issue we discuss the beginnings...
     

    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 5 hosted by Hostway
    Stay green...Green IT