jpw
jpw

Reputation: 19247

rails 3, using Devise, how add :lockable after the fact?

I am using devise successfully, but decided to add the :lockable module. Our table is called Users.

I cannot find docs on how to add a new devise module (or remove one) after doing an initial setup.

Upvotes: 12

Views: 3656

Answers (2)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

You should be able to do the following in a migration

change_table(:users) do |t|
  t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
end

The fields it adds are:

t.integer  "failed_attempts",                     :default => 0
t.string   "unlock_token"
t.datetime "locked_at"

Upvotes: 17

Dogbert
Dogbert

Reputation: 222198

Devise adds a call to devise in your model app/models/user.rb in your case. You can just add :lockable as a parameter to that.

Upvotes: 1

Related Questions