Skip to content
Syed Mudabbir Ali edited this page May 18, 2023 · 1 revision

Include the Gem: Add your "password_auth" gem to the Gemfile of your other application. Open the Gemfile file in the root directory of your application and add the following line:

ruby Copy code gem 'password_auth' Save the Gemfile and run the bundle install command in your terminal to install the gem and its dependencies.

Require the Gem: In your application code (e.g., in a controller, model, or any other relevant file), require the gem by adding the following line:

ruby Copy code require 'password_auth' Use the Gem's Functionality: Once the gem is installed and required, you can start using its functionality. In your case, you can use the hash_password and password_valid? methods provided by the "password_auth" gem.

For example, if you want to hash a password, you can use the following code:

ruby Copy code hashed_password = PasswordAuth.hash_password('password') To validate a password against a hashed password, you can use the following code:

ruby Copy code valid = PasswordAuth.password_valid?('password', hashed_password) Modify the code as per your specific requirements and use cases.

Restart the Server: After making changes to the Gemfile or the application code, restart your Rails server for the changes to take effect.

That's it! Your "password_auth" gem is now installed and ready to be used in your other application. You can leverage its methods and functionality wherever needed in your application code.

Clone this wiki locally