この記事の概要
・RubyOnRailsについて、Progateで学んだことを書き記す
・ガチ初心者によるもの
・主に備忘録として、随時書き足していく
項目
Controllerの生成
ターミナルで、以下のコマンドを実行
rails generate controller [コントローラー名] [アクション名]
結果)
①ルーティングが自動で追加される
②Controller、Viewが自動で生成される
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
①の詳細)
rails generate controller examples index
⇒作業ディレクトリ/config/routes.rbに、
get "examples/index" => "examples#index"
の一行が自動追加される。
②の詳細
rails generate controller examples index
⇒作業ディレクトリ/app/controllers/に、
examples_controller.rb が生成される
⇒作業ディレクトリ/app/views/に、
/examples/index.html.erb
が生成される