has_secure_password

#Gemfile
gem 'bcrypt'
class Admin < ActiveRecord::Base
  has_secure_password
end
class AddPasswordDigestToAdmins < ActiveRecord::Migration
  def change
    add_column :admins, :password_digest, :string
  end
end

In order to apply has_secure_password class method to your model, you will need password_digest attribute to be ready. Afterward, you can access model's password and password_confirmation attributes which were provided automatically by password_digest class method(which means you don't need to add password or password_confirmation columns on migrations manually).

Reference

results matching ""

    No results matching ""