コロン(:)の位置について
なんか色々使い分けがあるらしい。
:simbol
(前置)シンボルの宣言。見た目は文字列。扱いは数値。
hoge = { :name => :shige, :age => 10 }
:mojiretsu
(前置)文字列とか
<%= f.text_field :hoge %>
option:
(後置)railsのオプション
<%= f.text_field :hoge, autofocus: true %>
:method
(前置)railsでメソッドを表記
before_action :configure_permitted_parameters
これとかカオス。
before_action :configure_permitted_parameters, if: :devise_controller?
:configure_permitted_parameters ・・・メソッド
if: ・・・オプション
:devise_controller? ・・・メソッド
::
(ダブルコロン)は継承。
class ApplicationController < ActionController::Base 〜 end
class DeviseCreateUsers < ActiveRecord::Migration[7.0] 〜 end
ちなみに、上記2つはどちらもrubyファイルなんだけど、それぞれActionController::Base、ActiveRecord::Migration[7.0] を継承しているから、コントローラーファイルとマイグレーションファイルとして認識されるんだって。(へー。)
つまり、ActionController::Baseとかの中に、コントローラーたらしめる何かが書かれてるんだって。(メンターOが教えてくれた。 )