Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@ukoasis

Deviseでconfirmableの登録確認メールを受け取れない場合に登録を完了させる方法

More than 3 years have passed since last update.

概要

Deviseでconfirmable利用時にメールを送信できない、且つ、letter_openerなども使えない場合にどうやって登録を完了させるかを調べたのでメモ

環境

Ruby: 2.4.0
Rails: 5.0.1
Devise: 4.2.0

手順

  • Webの画面でemail, passwordを入力する
  • rails consoleで該当のUserを取得
  • Devise::Models::Confirmable#send_confirmation_instructionsを実行して、Mail objectを取得し、bodyをconsoleに表示させる
  • 本文中のURLをコピーしてブラウザで開く
  • Webの画面で変更するパスワードを入力して、登録を完了させる
> User.find(1).send_confirmation_instructions.body
   (0.2ms)  BEGIN
   (0.2ms)  COMMIT
  Rendering devise/mailer/confirmation_instructions.html.slim
  Rendered devise/mailer/confirmation_instructions.html.slim (0.6ms)
Devise::Mailer#confirmation_instructions: processed outbound mail in 115.8ms
Sent mail to fooooo+test5@test.cdd (4.1ms)
Date: Thu, 02 Feb 2017 17:36:46 +0900
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: fooooo+test5@test.cdd
Message-ID: <5892ef9eb1cea_1f423fd11ec464fc438b8@fooooo.mail>
Subject: xxxxx
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: base64

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

=> #<Mail::Body:0x007fa246f96100
 @boundary=nil,
 @charset=nil,
 @encoding="8bit",
 @epilogue=nil,
 @part_sort_order=["text/plain", "text/enriched", "text/html"],
 @parts=[],
 @preamble=nil,
 @raw_source=
  "<p>ようこそ、fooooo+test5@test.cddさん!</p><p>次のリンクでメールアドレスの確認が完了します:</p>
<p>

<a href=\"http://localhost:3000/users/confirmation?confirmation_token=xxxxxxxxxxxxxxxx&amp;locale=ja\">アカウント確認</a>
↑このURLをコピーして、ブラウザで開く
</p>">          

あとがき

letter_openerの素晴らしさを享受していたので使えない環境の場合どうするのか?とか思っていたが、Deviseも良く出来たライブラリだったので、意外と簡単に出来た
が、あまり情報は無かったので、やっぱレアケースなんだなと認識した

3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  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
ukoasis
pieceofcake
cakes(ケイクス)とnote(ノート)を運営しています

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?