空飛ぶITコンサルタント

中小企業診断士が「AI」「パン」「補助金」について語ります

そろそろ開発11 deviseのModel編集

deviseのModelを編集する。初期化は以下の通り。

class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:musers) do |t|
## Database authenticatable(注:1)
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""

## Recoverable(注:2)
t.string :reset_password_token
t.datetime :reset_password_sent_at

## Rememberable(注:3)
t.datetime :remember_created_at

## Trackable(注:4)
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip

## Confirmable(注:5)
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable

## Lockable(注:6)
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at

## Token authenticatable(注:7)
# t.string :authentication_token


t.timestamps
end

add_index :musers, :email, :unique => true
add_index :musers, :reset_password_token, :unique => true
# add_index :musers, :confirmation_token, :unique => true
# add_index :musers, :unlock_token, :unique => true
# add_index :musers, :authentication_token, :unique => true
end
end

(注:1)Database Authenticatable
ユーザがログインする際に必要となる項目。パスワードは暗号化される。
(注:2)Recoverable
パスワードのリセット機能を有する。標準で実装されているけど、動きは知らないので、調査が必要。
(注:3)Rememberable
クッキーを保存して、ユーザーの認証状況を保持します。
(注:4)Trackable
サインインのカウント・タイムスタンプ・IPアドレスを保持します。
(注:5)Confirmable
初回のユーザ登録した後に、確認Eメールを出すかの項目。
defaultではコメントアウトしているが、今回は有効にします。
(注:6)Lockable
ログインを失敗しすぎるとアカウントをロックする。
これはそのままコメントアウトでいいかな。
(注:7)Token authenticatable
認証トークンを使用するかどうかの項目。
これもそのままコメントアウトでいいかな。

明日は、maigreに行けたら...