建立 StaticPages controller
建立 Git 分支
$ git checkout -b static-pages
建立一個 StaticPages controller,和兩個 actions:「home」、「help」
$ rails generate controller StaticPages home help
Rails 會幫你產生一些與之相對應的輔助文件和路由
先提交
$ git add -A
$ git commit -m "Add a Static Pages controller"
執行 Rails server 瀏覽網頁
$ rails server
建立「Home」和「Help」的頁面內容
=> app/views/static_pages/home.html.erb
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
=> app/views/static_pages/help.html.erb
<h1>Help</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a href="http://www.railstutorial.org/#help">Rails Tutorial help section</a>.
To get help on this sample app, see the
<a href="http://www.railstutorial.org/book"><em>Ruby on Rails Tutorial</em>
book</a>.
</p>