Repository is archived
No commit activity in last 3 years
No release in over 3 years
Simple password model implemented on top of ActiveModel::Model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0

Runtime

>= 4.0.0
 Project Readme

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.