Module: Devise::Migrations

Defined in:
lib/devise/migrations.rb

Overview

Helpers to migration:

create_table :accounts do |t|
  t.authenticatable
  t.confirmable
  t.recoverable
  t.rememberable
  t.timestamps
end

However this method does not add indexes. If you need them, here is the declaration:

add_index "accounts", ["email"],                :name => "email",                :unique => true
add_index "accounts", ["confirmation_token"],   :name => "confirmation_token",   :unique => true
add_index "accounts", ["reset_password_token"], :name => "reset_password_token", :unique => true

Instance Method Summary collapse

Instance Method Details

#authenticatable(options = {}) ⇒ Object

Creates email, encrypted_password and password_salt.



22
23
24
25
26
27
# File 'lib/devise/migrations.rb', line 22

def authenticatable(options={})
  null = options[:null] || false
  string :email,              :limit => 100, :null => null
  string :encrypted_password, :limit =>  40, :null => null
  string :password_salt,      :limit =>  20, :null => null
end

#confirmableObject

Creates confirmation_token, confirmed_at and confirmation_sent_at.



31
32
33
34
35
# File 'lib/devise/migrations.rb', line 31

def confirmable
  string   :confirmation_token, :limit => 20
  datetime :confirmed_at
  datetime :confirmation_sent_at
end

#recoverableObject

Creates reset_password_token.



39
40
41
# File 'lib/devise/migrations.rb', line 39

def recoverable
  string :reset_password_token, :limit => 20
end

#rememberableObject

Creates remember_token and remember_created_at.



45
46
47
48
# File 'lib/devise/migrations.rb', line 45

def rememberable
  string   :remember_token, :limit => 20
  datetime :remember_created_at
end