LoginSignup
0
0

More than 3 years have passed since last update.

Devise と Active Admin で異なる認証(authentication_key)を使う方法

Posted at
  • 「ユーザー」 は username でログイン
  • 「管理者」 は email でログイン

のように、認証を異なる方法にしたくて悩んでいたところ簡単な方法を見つけました。

  • devise.rbconfig.authentication_keys = [:email] の1行をコメントアウト
  • admin_user.rbdevisedevise authentication_keys: [:email] に変更
  • user.rbdevisedevise authentication_keys: [:username] に変更

最初は devise.rbconfig.authentication_keys = [:email]:email:username と変えましたが、「管理者」も username で認証することとなってしまい、エラーが出ました。

【参考記事】 https://stackoverflow.com/questions/4633077/how-to-use-different-authentication-keys-for-two-devise-models

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0