【ror学习笔记1】配置和HelloWorld

用的是InstantRails1.7,里面内嵌ruby1.8.6 ,rails 1.2.3

教程是《Agile Web Development with Rails 2nd》,第四版出英文版了,据说第五版也快出了。

编辑器是SciTe

 

Hello world 步骤:

1.rails demo

2.ruby script/server

 

3.ruby script/generate controller Say

4.文件:

demo/app/controller\say_controller.rb

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

 

demo/app/views/say/hello.rthml

代码
<html>
<head>
<title>Hello,Rails!</title>
</head>
<body>
<h1>Hello from Rails!</h1>
<p>
It is now
<%= @time %>
</p>
<p>
Time to say
<%= link_to "Goodbye!",:action=>"goodbye" %>
<p>
</body>
</html>

 

demo/app/views/say/goodbye.rhtml

代码
<html>
<head>
<title>See you later!</title>
</head>
<body>
<h1>Goodbye!</h1>
<p>
It was nice having you here
</p>
<p>
Say
<%= link_to "Hello",:action=>"hello" %> again.
</p>
</body>
</html>

 

posted on 2010-10-30 13:37  张小捷  阅读(201)  评论(0)    收藏  举报

导航