Module: Devise::Schema
- Included in:
- Orm::ActiveRecord, Orm::DataMapper, Orm::MongoMapper, Orm::Mongoid
- 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
-
#apply_schema(name, type, options = {}) ⇒ Object
Overwrite with specific modification to create your own schema.
-
#authenticatable(options = {}) ⇒ Object
Creates email, encrypted_password and password_salt.
-
#confirmable ⇒ Object
Creates confirmation_token, confirmed_at and confirmation_sent_at.
-
#lockable ⇒ Object
Creates failed_attempts, unlock_token and locked_at.
-
#recoverable ⇒ Object
Creates reset_password_token.
-
#rememberable ⇒ Object
Creates remember_token and remember_created_at.
-
#token_authenticatable ⇒ Object
Creates authentication_token.
-
#trackable ⇒ Object
Creates sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip.
Instance Method Details
#apply_schema(name, type, options = {}) ⇒ Object
Overwrite with specific modification to create your own schema.
61 62 63 |
# File 'lib/devise/schema.rb', line 61 def apply_schema(name, type, ={}) raise NotImplementedError end |
#authenticatable(options = {}) ⇒ Object
Creates email, encrypted_password and password_salt.
Options
-
:null - When true, allow columns to be null.
-
:encryptor - The encryptor going to be used, necessary for setting the proper encrypter password length.
11 12 13 14 15 16 17 18 |
# File 'lib/devise/schema.rb', line 11 def authenticatable(={}) null = [:null] || false encryptor = [:encryptor] || (respond_to?(:encryptor) ? self.encryptor : :sha1) apply_schema :email, String, :null => null apply_schema :encrypted_password, String, :null => null, :limit => Devise::ENCRYPTORS_LENGTH[encryptor] apply_schema :password_salt, String, :null => null end |
#confirmable ⇒ Object
Creates confirmation_token, confirmed_at and confirmation_sent_at.
26 27 28 29 30 |
# File 'lib/devise/schema.rb', line 26 def confirmable apply_schema :confirmation_token, String, :limit => 20 apply_schema :confirmed_at, DateTime apply_schema :confirmation_sent_at, DateTime end |
#lockable ⇒ Object
Creates failed_attempts, unlock_token and locked_at
54 55 56 57 58 |
# File 'lib/devise/schema.rb', line 54 def lockable apply_schema :failed_attempts, Integer, :default => 0 apply_schema :unlock_token, String, :limit => 20 apply_schema :locked_at, DateTime end |
#recoverable ⇒ Object
Creates reset_password_token.
33 34 35 |
# File 'lib/devise/schema.rb', line 33 def recoverable apply_schema :reset_password_token, String, :limit => 20 end |
#rememberable ⇒ Object
Creates remember_token and remember_created_at.
38 39 40 41 |
# File 'lib/devise/schema.rb', line 38 def rememberable apply_schema :remember_token, String, :limit => 20 apply_schema :remember_created_at, DateTime end |
#token_authenticatable ⇒ Object
Creates authentication_token.
21 22 23 |
# File 'lib/devise/schema.rb', line 21 def token_authenticatable apply_schema :authentication_token, String, :limit => 20 end |
#trackable ⇒ Object
Creates sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip.
45 46 47 48 49 50 51 |
# File 'lib/devise/schema.rb', line 45 def trackable apply_schema :sign_in_count, Integer 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 |