https://github.com/launchpadlab/lp_confirmable
Simple confirmable logic for Rails apps
https://github.com/launchpadlab/lp_confirmable
Last synced: 10 months ago
JSON representation
Simple confirmable logic for Rails apps
- Host: GitHub
- URL: https://github.com/launchpadlab/lp_confirmable
- Owner: LaunchPadLab
- License: mit
- Created: 2017-02-06T16:53:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-07T17:28:36.000Z (almost 9 years ago)
- Last Synced: 2025-04-09T19:55:23.935Z (10 months ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# LP Confirmable
Simple confirmable logic for Rails apps. No baked in routing or mailers, just the barebones logic and migration you need to implement confirmable logic for your users.
## Installation
Add `gem 'lp_confirmable', github: 'launchpadlab/lp_confirmable'` to your Gemfile and run `bundle install`.
## Usage
For the purposes of these instructions, I will assume the model you are using is 'User' but it could be anything you want.
1. Generate a migration to add the required fields to the model of your choice with `bundle exec rails generate lp_confirmable:model User`
2. Run the migration with `bundle exec rails db:migrate`. This adds three columns to your table: `confirmation_token`, `confirmed_at`, and `confirmation_sent_at`.
3. When you want to start the process, assume you have created a `user`, then call `LpConfirmable::Model.set_confirmation_token! user`. This will return the token that you can share with the client via email, link, smoke-signals, whatever.
4. While you are in charge of sending confirmation instructions, `lp_confirmable` still needs to track it, so when you are ready call
```
LpConfirmable::Model.send_confirmation_instructions! user do
end
```
and 'lp_confirmable' will take care of the rest.
5. To confirm a user, call `LpConfirmable::Model.confirm_by_token!(User, confirmation_token)`. This will find the user by confirmation token and confirm them, returning the user model.
6. Any errors that pop up along the way, such as trying to confirm a non-confirmable object, or an expired token, etc..., will throw an `LpConfirmable::Error`.
7. To change the global defaults run `bundle exec rails generate lp_confirmable:install` to generate an initializer at `../config/initalizers/lp_confirmable.rb`. See the initializer for more details.
## Development
+ `git clone git@github.com:LaunchPadLab/lp_confirmable.git`
+ `bundle install`
+ Test with `rake`
## Confirm away!