Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Page 4 - Understanding Action Views in Ruby-on-Rail...
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 
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

Understanding Action Views in Ruby-on-Rails
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2006-08-15

    Table of Contents:
  • Understanding Action Views in Ruby-on-Rails
  • ActionView: Templates and Formatting Helpers
  • ActionView: Pagination and Layouts
  • 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


    Understanding Action Views in Ruby-on-Rails - Rails in the Real World


    (Page 4 of 4 )

    Let's take the simple application that was created in the last part a little further. To jog your memory here is the code for the Controller:

    class SayController < ApplicationController
         def
    hello
             
    @time=Time.now
         end
    end

    and for the View:

    <html>
      <head>
        <title>Hello, Rails!</title>
      </head>
      <body>
        <h1>Hello from Rails! The time now is<%=@time%></h1>
      </body>
    </html>

    Now let's add a string and float variable to the controller.

    class SayController < ApplicationController
      def
    hello
        @time=Time.now
          @rule=”All sentence should have a starting, a
                 mid section and an 
    end except”
          @price=1000.123
      end
    end

    In the View let's use the formatting helpers (the view is already a template):

    <html>
      <head>
        <title>Hello, Rails!</title>
      </head>
      <body>
        <br>The time now is
    <%=@time%>
        <br>The time now in words
    <%= distance_of_time_in_words(@time, Time.local(2005, 12, 25)) %>
        <br>The highlight works like this
    <%= highlight(@rule, "sentence") %>
        <br>The price 1000.123 in Canadian dollar is
    <%= number_to_currency(@price, :unit => "CAN$", :precision => 2) %>
      </body>
    </html>

    That’s all for this part. In the next part the last piece of the puzzle, i.e. the Model component, will be discussed. Once that is completed, I will start to discuss all the components in relation to each other using a project. Till then…


    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.

       · Presenting the data to the user in a palatable way is one of the major functionality...
     

    RUBY-ON-RAILS ARTICLES

    - Callbacks and the Active Record
    - Validation and the Active Record
    - Arrays, Associations and the Active Record
    - Associations and Dependencies with Active Re...
    - Advanced Active Record: Enhancing Your Models
    - Load Balancing Databases with Rails
    - More Advanced Database Features and Rails
    - Handling Advanced Database Features with Rai...
    - Managing Database Files with Ruby on Rails
    - Databases and Ruby on Rails
    - Updating and Deleting with the Active Record
    - Rails Active Record and CRUD Functions
    - Working with a Database: Active Record
    - The MVC Pattern in the Rails Framework
    - Advantages of the Rails Framework







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek