Home arrow Ruby-on-Rails arrow Page 4 - Ruby On Rails: Making Your First Dynamic Site
RUBY-ON-RAILS

Ruby On Rails: Making Your First Dynamic Site


In our last article we learned how to create a static web page with Rails and learned all about the workings of the grand Model-View-Controller architecture. In this article I am going to teach you how to create dynamic pages using Rails as your framework.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
May 05, 2008
TABLE OF CONTENTS:
  1. · Ruby On Rails: Making Your First Dynamic Site
  2. · Viewing Your Page
  3. · Creating Two Views and Choosing Between Them
  4. · Choosing Which View to View

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Ruby On Rails: Making Your First Dynamic Site - Choosing Which View to View
(Page 4 of 4 )

Since we are essentially creating a time-clock that reminds us when to work, eat lunch, and go home, we will have to edit the controller file to make our actions trigger based on the time of day.

Go ahead and open the decision.rb file and modify the code so it matches mine:


class DecisionController < ApplicationController

def start

end

def lunch

if Time.now == 12

render(:action => :lunch)

end

end

def home

end

end

If you run this program and the hour is 12, it will show the lunch view. You can also modify the code so that if it is in hour 5, it will show home, and hour 9 it will show the start view.

Well that's all the time we have for this article. In our next episode we will discuss how to build a simple application and how to link to actions.

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.

blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- 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
- Ruby on Rails Templates and Layouts
- Action Pack Controller Creation
- Writing an Action Pack Controller

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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