コントローラー/アクション/ビューの作成
雛形が以下のようなコマンドで作成できるらしい。
#ruby script/generate controller コントローラ名 アクション名1 アクション名2 ...
やってみる
#ruby script/generate controller main hello
http://localhost:3000/main/hello
にアクセスできた。
"mysql_hello\app\controllers\main_controller.rb"は以下のようになっている。
class MainController < ApplicationController def hello end end
viewは"mysql_hello\app\views\main\hello.html.erb"でこんな感じ。
<h1>Main#hello</h1> <p>Find me in app/views/main/hello.html.erb</p>