Komei22 / rails-tutorial

rails-tutorialのsample_app作っていきます
0 stars 0 forks source link

ch12.2.4演習 #77

Closed Komei22 closed 7 years ago

Komei22 commented 7 years ago

演習1

新しいユーザーを登録したとき、リダイレクト先が適切なURLに変わったことを確認してみましょう。その後、Railsサーバーのログから送信メールの内容を確認してみてください。有効化トークンの値はどうなっていますか?

サーバログの送信メール内容

----==_mimepart_595f18276b045_a3b83fe8e1c609a890298
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi hogehoge,

Welcome to the Sample App! Click on the link below to activate your account:

http://localhost:3000/account_activations/7vvcxA6DZKlVU9o1A3ScgQ/edit?email=hogehoge%40example.com

----==_mimepart_595f18276b045_a3b83fe8e1c609a890298
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
      /* Email styles need to be inline */
    </style>
  </head>

  <body>
    <h1>Sample App</h1>

<p>Hi hogehoge,</p>

<p>
Welcome to the Sample App! Click on the link below to activate your account:
</p>

<a href="http://localhost:3000/account_activations/7vvcxA6DZKlVU9o1A3ScgQ/edit?email=hogehoge%40example.com">Activate</a>

  </body>
</html>

演習2

コンソールを開き、データベース上にユーザーが作成されたことを確認してみましょう。また、このユーザーはデータベース上にはいますが、有効化のステータスがfalseのままになっていることを確認してください。

irb(main):005:0> User.find_by(name: 'hogehoge')
  User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."name" = ? LIMIT ?  [["name", "hogehoge"], ["LIMIT", 1]]
=> #<User id: 101, name: "hogehoge", email: "hogehoge@example.com", created_at: "2017-07-07 05:12:07", updated_at: "2017-07-07 05:12:07", password_digest: "$2a$10$.g1vkofOXTtN9BYDHIgBV.u4oSIHlVaZquegceXpPLs...", remember_digest: nil, admin: false, activation_digest: "$2a$10$QW4432mEeXRWE95f3jO.cO6ucVDJdOvD6UE7Ms.GdZJ...", activated: false, activated_at: nil>