rails解説セミナー 第12章
TRANSCRIPT
http://railstutorial.jp/
Rails
by YassLab
12 #Rails
Slideshare
http://www.slideshare.net/yasulab/presentations
Cloud9
1. 2. URL 3.
https://ide.c9.io/yasulab/rails-tutorial
https://rails-tutorial-yasulab.c9users.io/
URL “Collaborate” → “Group Chat”
! :)
Ready?
!
http://railstutorial.jp/
Rails
by YassLab
12 #Rails
11 📨 🔒
•
12 📨 🔓
•
13 📮 🐤
•
14 👤 👤
•
📝
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
📝 email !
DB
📨
✅ URL
❌ (NG )
⭕(OK )
edit form
1. PasswordResets
• PasswordResets
2.
• View, Preview, Form, Test
3.
• edit
4.
• Heroku + SendGrid
http://railstutorial.jp/
Rails
by YassLab
12
📝 email !
DB
📨
✅ URL
❌ (NG )
⭕(OK )
edit form
( )
User.find_by(📨)
@user.authenticated?(🔑)
reset_digest
email 😸
$2a$10$Kc/EY79ieCTBVYFktWkUKOhhY0kItaYPAyMsT23rvAR…
vpb8MgPiJyI5UlRjfeuAZA🔑
📨🔑
✅
1. 📨 email 📝
2. 🔐 email DB 🔑
3. 📮 DB 📨
4. 🔑 DB 🔍
5. ✅ ※ 🤔
reset_digest ,
reset_sent_at
User . 👉
http://railstutorial.jp/
Rails
by YassLab
12 PasswordResets
PasswordResets
• PasswordResets $ rails generate controller PasswordResets new edit --no-test-framework $ rails generate migration add_reset_to_users reset_digest:string reset_sent_at:datetime
• PasswordResets Login Password Reset .Login new.html.erb .
🔧💨
http://railstutorial.jp/
Rails
by YassLab
12
Router
Controller
View
Model
DatabaseReq.
HTML
📨👉
👈 Action
Mailer 📮
Mail ✉
1. ✉ = @user.email 2. 🔑 = @user.reset_token 👉 GET /password_resets/🔑/edit?email=✉
✉ 🤔
User.find_by(📨)
@user.authenticated?(🔑)
vpb8MgPiJyI5UlRjfeuAZA🔑
📨🔑
• ✅ ActionMailer ! $ rails generate mailer UserMailer \ account_activation password_reset 👈
• ✅ PasswordResets
delivery_method = :test .
• ActionMailerPreview https://rails-tutorial-yasulab.c9users.io/rails/mailers/user_mailer/account_activation
📮 UserMailer
• Rails :test/mailers/user_mailer_test.rb
• View ✅ ?✅ ?✅ ?✅ ?
🔎
host ! ✅
🔧💨
http://railstutorial.jp/
Rails
by YassLab
12
📝 email !
DB
📨
✅ URL
❌ (NG )
⭕(OK )
edit form
( )
authenticated? ( )👇 !
@user.authenticated?(🔑)
remember_token remember_digest
activation_token activation_digest
reset_token reset_digest
“#{ }_digest” “#{ }_token”
🤔 ? • Ruby send !
( )
• 👉 ✨
🔧💨
📝 email !
DB
📨
✅ URL
❌ (NG )
⭕(OK )
edit form
( )
🔎✅
1. ?
2.
3. ?
( 🆗 🆖)
4.
👆 / ✅
: 🤔
http://railstutorial.jp/
Rails
by YassLab
12
( )
• Heroku SendGrid add-on $ heroku addons:create sendgrid:starter
• SendGrid config/environments/production.rb $ heroku config:get SENDGRID_USERNAME$ heroku config:get SENDGRID_PASSWORD
• Heroku
• !
( )
? 🤔
? 🤔
1. PasswordResets
• PasswordResets
2.
• View, Preview, Form, Test
3.
• edit
4.
• Heroku + SendGrid
📝 email !
DB
📨
✅ URL
❌ (NG )
⭕(OK )
edit form
✅ 11 📨 🔒
•
✅ 12 📨 🔓
•
13 📮 🐤
•
14 👤 👤
•
Action Mailer http://railsguides.jp/action_mailer_basics.html
Active Job http://railsguides.jp/active_job_basics.html
Rails http://railsguides.jp/testing.html
http://railstutorial.jp/
Rails
by YassLab
12 #Rails