Deviseで追加したカラムを更新する

Deviseで追加したカラムを更新する時のメモ。追加したカラムの編集が反映されないエラーではまっていたのですが、いくつか記事を読みあさったところStrongParameterではじかれているとのこと。記事とドキュメントを参考にカラムを更新対象に追加する処理を行いました。

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:account_update) << :username
  end
end

指定できるアクション

  • sign_in
  • sign_up
  • account_update

参考