Upload
yohei-yasukawa
View
129
Download
1
Embed Size (px)
Citation preview
http://railstutorial.jp/
Rails
by YassLab
11 #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
11 #Rails
1.
• /
2.
•
3.
• Pagination
4.
• Strong Prameters ( )
7 108~9
✅ ↓
🔧
11 📨 🔒
•
12 📨 🔓
•
13 📮 🐤
•
14 👤 👤
•
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
1. AccountActivations
• AccountActivations MVC
2.
• View / Preview / Test
3.
• authenticated?
4.
• Heroku + SendGrid
http://railstutorial.jp/
Rails
by YassLab
11
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
( )
ID
User.find_by(❓)
@user.authenticate(🔑)$2a$10$Kc/EY79ieCTBVYFktWkUKOhhY0kItaYPAyMsT23rvAR…
remember_digest
signed[:user_id]340394
vpb8MgPiJyI5UlRjfeuAZA🔑user_id: 3
email 😭
User.find_by(📨)
@user.authenticated?(🔑)
activation_digest
email 😸
$2a$10$Kc/EY79ieCTBVYFktWkUKOhhY0kItaYPAyMsT23rvAR…
vpb8MgPiJyI5UlRjfeuAZA🔑
📨🔑
1. 👤 Unactivated ( )
2. 🔐 Signup
3. 📨 DB Signup
4. 🔑 email DB
5. ✅ home
※ 8~9 remember_token / remember_digest 🤔
http://railstutorial.jp/
Rails
by YassLab
11 AccountActivations
AccountActivations
• AccountActivations $ rails generate controller AccountActivations --no-test-framework
• resources :account_activations, only: [:edit]
• $ rails generate migration add_activation_to_users activation_digest:string activated:boolean activated_at:datetime
AccountActivations
🔧💨
http://railstutorial.jp/
Rails
by YassLab
11
Router
Controller
View
Model
DatabaseReq.
HTML
📨👉
👈 Action
Mailer 📮
Mail ✉
1. ✉ = @user.email 2. 🔑 = @user.activation_token 👉 GET /account_activations/🔑/edit?email=✉
✉ 🤔
User.find_by(📨)
@user.authenticated?(🔑)
vpb8MgPiJyI5UlRjfeuAZA🔑
📨🔑
• ActionMailer ! $ rails generate mailer UserMailer \ account_activation password_reset
• AccountActivations
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
11
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
🔧
• signup 🆖✉ flash .
signup create
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
🔧
authenticated? 👇 !
@user.authenticated?(🔑)
remember_token remember_digest
activation_token activation_digest
reset_token reset_digest
“#{ }_digest” “#{ }_token”
🤔 ? • Ruby send !
( )
• 👉 ✨
🔧💨
: signup login
!
: assigns
@user
users_signup_test.rb
users_controller.rb
http://railstutorial.jp/
Rails
by YassLab
11
• 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. AccountActivations
• AccountActivations
2.
• View, Preview, Test
3.
• authenticated?
4.
• Heroku + SendGrid
DB
📨
✅ URL
❌ (NG )
⭕ (OK )
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
11 #Rails