LoginSignup
2
3

More than 5 years have passed since last update.

Devise覚書

Last updated at Posted at 2018-05-17

DeviseのConfirmが効いている状態で、アドミンが他のログインユーザーを作成する場合

  • 普通のuser.new部分で confirmed_at を入れてあげればいい。
  • Deviseのconfirmableのメール飛ばすロジックはdevise/lib/devise/models/confirmable.rbにある。
  • Deviseのconfirmableはconfirmed_atにtimeを入れることで発動する。
user_controller.rb

  def create
    User.new(user_params)
    ##省略
  end

  private

  def user_params
    confirmed_at = Time.zone.now
    params.fetch(:user, {}).permit(:confirmed_at)
  end

これでアドミンが作成したユーザのアドレスに認証メールが飛ぶ。

devise日本語化

2
3
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
2
3