用rails命令创建一个应用程序
rails new demo
cd demo
rails g controller home index
rails s
打开app/controllers/home_controller.rb文件,
def index
@time = Time.now
end
打开app/views/index.html.erb文件,
<h1>Hello rails</h1>
<p>
It is now<%= @time %>
</p>
打开浏览器,输入http://localhost:3000/home/index
页面显示出
Hello rails
It is now 2013-08-20 22:06:17-0500UTC
rails new demo
cd demo
rails g controller home index
rails s
打开app/controllers/home_controller.rb文件,
def index
@time = Time.now
end
打开app/views/index.html.erb文件,
<h1>Hello rails</h1>
<p>
It is now<%= @time %>
</p>
打开浏览器,输入http://localhost:3000/home/index
页面显示出
Hello rails
It is now 2013-08-20 22:06:17-0500UTC