Help us understand the problem. What is going on with this article?

【Rails】Deviseでのstrong parameters指定はdevise_parameter_sanitizer.forではなくdevise_parameter_sanitizer.permitを使うようになったらしい

More than 3 years have passed since last update.

Railsの認証を簡単にするプラグインdeviseで、strong parametersをいじろうとした。

適当に日本語サイトなどを調べてdevise_parameter_sanitizer.forをApplicationControllerに追加したが、上手くいかない。ということでGithubのREADMEを読んでみると、どうやら変更があったようだ

https://github.com/plataformatec/devise#strong-parameters

こんな感じで書くといいらしい。

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

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
  end
end

ちなみにpermitの第一引数は、:sign_in, :sign_up, :account_updateのいずれか。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away