[Rails] 建立頁面
更新日期:1. 進入專案資料夾
cd ~/Projects/NewProjectName
2. 新增Controller
rails g controller ControllerName
3. 修改產生出來的controller
$vim app/controllers/ControllerName_controller.rb
class PageNameController < ApplicationController
def PageName <===改自己要的頁面名字
end
end
4. 建立一個新的空白View頁面
$touch app/views/ControllerName/PageName.html.erb
5. 加入頁面html
$vim app/views/ControllerName/PageName.html.erb
6. 加入Routing
$vim config/routes.rb
Rails::Application.routes.draw do
...
get "ControllerName/PageName" => "ControllerName#PageName" <===路徑可以隨便定
...
end