controller
使い方をターミナル上で聞いてみる
$ rails g controller
code:terminal
Usage:
rails generate controller NAME action action options
action
controller に書かれたメソッドのこと
なるほど〜〜〜
コマンドで必要なファイルが生成されるのでミスをしづらい
すごい
コマンドは使わずゼロから作ってもいい
例)
$ rails g controller hello index
hello という名前
index というアクション
作られたファイル
app/controllers/hello_controller.rb ★重要
app/views/hello/index.html.erb ★重要
test/controllers/hello_controller_test.rb
app/helpers/hello_helper.rb
app/assets/javascripts/hello.coffee
app/assets/stylesheets/hello.scss
config/routes.rb ★重要
$ rails s
してもうまく表示されないときがあった
ディレクトリを削除して同名のディレクトリを再度つくったとき
別名の名前(ディレクトリ)で rails new し直して回避した
キャッシュによるもの?
一度 routing でのエラーが出てしまうとうまくいかないときがあるっぽい?