Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 615
jpw Avatar asked Mar 23 '11 23:03

jpw


2 Answers

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"
like image 117
Jesse Wolgamott Avatar answered Oct 02 '22 04:10

Jesse Wolgamott


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.

like image 41
Dogbert Avatar answered Oct 02 '22 04:10

Dogbert