Skip to content
Simple password model implemented on top of ActiveModel::Model
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/active_model
test
.gitignore
Gemfile
LICENSE
README.md
Rakefile
active_model-password.gemspec

README.md

ActiveModel::Password

ActiveModel::Password is a lightweight password model implemented on top of ActiveModel::Model.

Installation

Add this line to your application's Gemfile:

gem "active_model-password"

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_model-password

Usage

The most popular workflow is:

class PasswordsController < ApplicationController
  def edit
    @password = ActiveModel::Password.new
    @password.user = current_user
  end

  def update
    @password = ActiveModel::Password.new(password_params)
    @password.user = current_user
    if @password.save
      redirect_to root_url, notice: "Password changed successfully."
    else
      render :edit
    end
  end

  private

  def password_params
    params.require(:active_model_password).permit(:password, :password_confirmation)
  end
end

If you don't like the default behavior, you can always inherit the password model and override some defaults.

Copyright

Copyright © 2014 Kuba Kuźma. See LICENSE for details.

Something went wrong with that request. Please try again.