アプリのコントローラーは各コントローラー名の前にapplication_controllerを通ってから処理をしていく。
そのためbefore~~はこのapplication_controller
の中に記述する。
before_action :authenticate_user!
上記の意味は
ログインしていないユーザーをログインページの画面に促すことができる。
before_action :configure_permitted_parameters, if: :devise_controller?
private
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end
deviseを使った新規登録をする際に使用。
例えば新規登録でemail,passwordだけでなく名前を追加で新規登録させたい場合に使う。(email,passwordはデフォルトで入っているので記述の必要はなし)permit下の処理名一覧