Users and Authentication

11th lecture, June 24, 2019

Projects in Information Technology II

http://www.sw.it.aoyama.ac.jp/2019/Projects2/lecture11.html

Martin J. Dürst

AGU

© 2019 Martin J. Dürst 青山学院大学

ミニテスト

 

Today's Schedule

 

Last Lecture's Exercises

 

Caution: Migrations

Wrong Steps:

  1. Create migration (rails generate migration ...)
  2. Execute migration (rails db:migrate)
  3. Edit migration

Correct Steps:

  1. Create migration (rails generate migration ...)
  2. Edit migration
  3. Execute migration (rails db:migrate)

Important: NEVER edit a migration that is already executed!

  

Solutions after accidental Wrong Steps

Two alternatives

  1. Move ahead:
    1. Check current state of database (e.g. with SQLiteStudio) and migrations (with rails db:migrate:status)
    2. (If possible, revert edits in migration)
    3. Use new migration (with correct steps) to add/change missing parts
  2. Revert:
    1. (Check current state of database (e.g. with SQLiteStudio) and migrations (with rails db:migrate:status))
    2. Revert edits in migration
    3. Revert migration itself (rails db:rollback STEP=1 for a single migration)
    4. Edit migration
    5. Execute migration again (rails db:migrate)

  

Frequently Used Controller/View Variables

  

Ruby Operators: Conditional Message Send

  

Link_To

  

Forms: form_with vs. form_tag

Function Form for Model Object Independent Form
Command form_with form_tag
Block variable form -
Label label label_tag
Submission submit submit_tag

  

Authentication, Authorization, Accounting (AAA)

  

Rails Password Field

If a field is declared as type digest, then Rails helps as follows:

However, Rails does not automatically provide the following:

  

Exercises: General Remarks

Exercise Overview

  

Exercise 11a: A User Model

  

Exercise 11b: Connecting Reviews and Users

 

Exercise 11c: Create a Sessions Controller

  

Homework

(no need to submit)