>rails demo
>cd demo
>ruby script/server
further more,create a controller
demo> ruby script/generate controller Say
You’ll find it in the file app/controllers/say_controller.rb
class SayController < ApplicationController
end
then,create an action and name it hello
class SayController < ApplicationController
def hello
end
end
we also need to create a file called
app/views/say/hello.rhtml
<html>
<head>
<title>Hello, Rails!</title>
</head>
<body>
<h1>Hello from Rails!</h1>
</body>
</html>
now you can visit your site:
本文详细介绍如何使用Ruby on Rails创建一个简单的Web应用。包括创建控制器、定义动作、制作视图文件等步骤,最后通过示例展示如何访问搭建好的站点。
350

被折叠的 条评论
为什么被折叠?



