#ただviewは枚数が多いので一旦どんなものがあるかぐらいで、止めます。
1. できたview
まずviewはこれだけあった。
結構あるようだ。
認識していたのは
- sessions
- registrations
- passwords
の3つ。
それ以外は多分以下。
#予測の説明付記。
- confirmations:何らかの確認を行うための画面。『このデータでユーザ登録しますか?』『パスワードを初期化していいですか?』的な。
- mailer:メールを送信する画面。パスワードリセットとかだろうか?
- shared:コレはちょっと分からん。
- unlocks:コレはロックされたアカウントの解放だと思われる。
2. できたモデル
#日本語コメントはコッチで付記。
class DeviseUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
# (このクラスは)デフォルトのデバイスモジュールを含んでいます。
# コレ以外にも
# :token_authenticable トークン認証可否
# :confirmable 確認可否
# :lockable アカウントロック可否
# :timeoutable タイムアウト制御可否
# :omniauthable OmniAuth可否
# があります。
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
# このモデルでのアクセサ(Javaでいうとgetter,setter)を定義します
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
# title, body属性へのアクセサはコメントアウトしています。
end
deviseメソッド(devise :database_authenticable, … の部分)がこのモデルのポイントになると思うので今度のぞいてみよう。
3. できたマイグレーション
最後にテーブル作成マイグレーション(コレ長い)
#コチラも日本語コメントはコチラで付記。
class DeviseCreateDeviseUsers < ActiveRecord::Migration
def change
create_table(:devise_users) do |t|
## Database authenticatable
# データベース認証用カラム(メールアドレス, 暗号化パスワード)
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
# アカウント復旧用カラム(パスワードリセット用トークン, リセットパスワード送信先
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
# 思い出し用(よくわからん)カラム
t.datetime :remember_created_at
## Trackable
# アカウント履歴用カラム(ログイン回数, 現行ログイン時刻, 最終ログイン時刻, 現行ログインIP, 最終ログインIP)
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
# 確認用カラム(デフォルト封印)
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# ロック用カラム(デフォルト封印)
# 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
# トークン認証用カラム(デフォルト封印)
# t.string :authentication_token
t.timestamps
end
# インデックス作成
add_index :devise_users, :email, :unique => true
add_index :devise_users, :reset_password_token, :unique => true
# add_index :devise_users, :confirmation_token, :unique => true
# add_index :devise_users, :unlock_token, :unique => true
# add_index :devise_users, :authentication_token, :unique => true
end
end

0 件のコメント:
コメントを投稿