やりたいこと:
Railsでdeviseのコードをオーバーライドし変更を加える => 入力されたemail addressがユーザー登録済みかどうかを判別。
下記のコード内に、入力されたemail addressが登録済みであるかの分岐を作成。
(登録済みの場合は、『登録済み』の文言のメールを送信。登録されていない、もしくは登録未完了の場合は、confirmation_instructionsのメールを送信)
ruby
1 def create 2 self.resource = resource_class.send_confirmation_instructions(resource_params) 3 yield resource if block_given? 4 5 if successfully_sent?(resource) 6 respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name)) 7 else 8 respond_with(resource) 9 end 10 end
resource.persisted?、record.persisted?など試していますが上手くいかず、入力されるemailの既存か新規かの、判別方法が分かりません。
ご存知の方、ご教授頂けましたら幸いです。
Rails 5
devise 4.2.0
あなたの回答
tips
プレビュー