Ruby on rails开发从头来(windows)(三)-实现页面间的跳转2011-12-02 博客园 Cure在上篇随笔Ruby on rails开发从头来(windows)(二)-创建项目和第一个Hello world 中,我们介绍了如何使用InstantRails创建一个项目和编写一个简单的Helloworld页面,今天在上次的基础上,写一个简单的页面跳转。1.将appcontrollers目录下的say_controller.rb文件的内容改成下面这样:
class SayController < ApplicationController def Hello @time = Time.now end def goodby endend
我们看到和上篇随笔中的内容相比,添加了:
def goodbyend
2.修改appviewssay目录下的hello.rhtml的内容:
<html><p>Say <a href="/say/goodbye">GoodBye</a>!</p></html>
3.下面我们要在appviewssay目录下创建一个goodbye.rhtml文件,内容如下:
<html><head><title>See You Later!</title></head><body><h1>Goodbye!</h1><p>It was nice having you here.</p></body></html>