Module: Devise::Schema

Included in:
Orm::ActiveRecord, Orm::DataMapper, Orm::MongoMapper
Defined in:
lib/devise/schema.rb

Overview

Holds devise schema information. To use it, just include its methods and overwrite the apply_schema method.

Instance Method Summary collapse

Instance Method Details

#apply_schema(name, type, options = {}) ⇒ Object

Overwrite with specific modification to create your own schema.

Raises:

  • (NotImplementedError)


69
70
71
# File 'lib/devise/schema.rb', line 69

def apply_schema(name, type, options={})
  raise NotImplementedError
end

#authenticatable(*args) ⇒ Object



6
7
8
9
# File 'lib/devise/schema.rb', line 6

def authenticatable(*args)
  ActiveSupport::Deprecation.warn "t.authenticatable in migrations is deprecated. Please use t.database_authenticatable instead.", caller
  database_authenticatable(*args)
end

#confirmableObject

Creates confirmation_token, confirmed_at and confirmation_sent_at.



34
35
36
37
38
# File 'lib/devise/schema.rb', line 34

def confirmable
  apply_schema :confirmation_token,   String
  apply_schema :confirmed_at,         DateTime
  apply_schema :confirmation_sent_at, DateTime
end

#database_authenticatable(options = {}) ⇒ Object

Creates email, encrypted_password and password_salt.

Options

  • :null - When true, allow columns to be null.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/devise/schema.rb', line 15

def database_authenticatable(options={})
  null    = options[:null] || false
  default = options[:default] || ""

  if options.delete(:encryptor)
    ActiveSupport::Deprecation.warn ":encryptor as option is deprecated, simply remove it."
  end

  apply_schema :email,              String, :null => null, :default => default
  apply_schema :encrypted_password, String, :null => null, :default => default, :limit => 128
  apply_schema :password_salt,      String, :null => null, :default => default
end

#lockableObject

Creates failed_attempts, unlock_token and locked_at



62
63
64
65
66
# File 'lib/devise/schema.rb', line 62

def lockable
  apply_schema :failed_attempts, Integer, :default => 0
  apply_schema :unlock_token,    String
  apply_schema :locked_at,       DateTime
end

#recoverableObject

Creates reset_password_token.



41
42
43
# File 'lib/devise/schema.rb', line 41

def recoverable
  apply_schema :reset_password_token, String
end

#rememberableObject

Creates remember_token and remember_created_at.



46
47
48
49
# File 'lib/devise/schema.rb', line 46

def rememberable
  apply_schema :remember_token,      String
  apply_schema :remember_created_at, DateTime
end

#token_authenticatableObject

Creates authentication_token.



29
30
31
# File 'lib/devise/schema.rb', line 29

def token_authenticatable
  apply_schema :authentication_token, String
end

#trackableObject

Creates sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip.



53
54
55
56
57
58
59
# File 'lib/devise/schema.rb', line 53

def trackable
  apply_schema :sign_in_count,      Integer, :default => 0
  apply_schema :current_sign_in_at, DateTime
  apply_schema :last_sign_in_at,    DateTime
  apply_schema :current_sign_in_ip, String
  apply_schema :last_sign_in_ip,    String
end