Admin Invitable
Admin Invitable is a gem that allows devise invitable gem to work with ActiveAdmin nicely. To clarify, the common use will be super administrators inviting administrators with less privileges.
Installation
Add to your Gemfile and install the following gems...
gem "admin_invitable"
Then, run the installer:
$ rails generate admin_invitable:install
This will copy the following files:
-
your_app/app/views/devise/invitations/edit.html.erb
. This is the form that will be used to change the password (this form uses Active Admin helpers and styles) -
your_app/app/views/devise/mailer/invitation_instructions.html.erb
. Email template that will be sent to invited users.
You can customize these files if you need.
Usage
Supposing you want to invite administrators, you need to have an Admin
model and...
$ rails generate devise_invitable Admin
Then, somewhere in your code, a super admin will have access to perform:
Admin.invite!(email: "newadmin@platan.us")
This will send the email (invitation_instructions.html.erb
) to newclient@platan.us with a link to the form (edit.html.erb
). After choosing the password, the admin will by redirected into Active Admin dashboard.
You must kwow this gem uses the devise invitable default path to work with Active Admin. If you want to make "normal" besides "admin" invitations, you need to create custom paths for "normal" resources. For example: if you want to invite Admin
s and Client
s you will need to generate views for clients like this:
$ rails generate devise_invitable:views clients
Then, clients will be redirected to the app and administrators to Active Admin.
Example
If you want to see an example you can:
- Clone the repository
- Run
$ rails s
inside/admin_invitable/spec/dummy
- Open browser at
localhost:3000
Publishing
On master/main branch...
- Change
VERSION
inlib/admin_invitable/version.rb
. - Change
Unreleased
title to current version inCHANGELOG.md
. - Run
bundle install
. - Commit new release. For example:
Releasing v0.1.0
. - Create tag. For example:
git tag v0.1.0
. - Push tag. For example:
git push origin v0.1.0
.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Thank you contributors!
Admin Invitable is maintained by platanus.
License
Admin Invitable is © 2021 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.