>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:
http://localhost:3000/say/hello
本文介绍如何使用Ruby on Rails创建一个简单的Web应用。首先通过命令行创建控制器,然后定义hello动作并建立视图文件。完成这些步骤后,可以在本地运行查看效果。
1924

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



