Landlord is a Rails engine that provides multi-tenant functionality for your SaaS application. Landlord includes:
- Multi-tenant accounts (with resources scoped to individual accounts)
- Stripe recurring billing (with automated receipts)
- User authentication provided by Devise
- Multiple-account membership for users (with roles)
- Custom account/user settings provided by Ledermann Rails Settings
- Custom user/role permissions provided by Pundit
Clone this repo, navigate to the repo root path in your terminal/command prompt, then run:
$ bundle install
$ rails db:setup
Update /test/dummy/config/application.yml
with your Stripe/Google OAuth API keys:
stripe_api_key: your_value_goes_here
stripe_publishable_key: your_value_goes_here
stripe_webhook_secret: your_value_goes_here
google_client_id: your_value_goes_here
google_client_secret: your_value_goes_here
Then run:
$ cd test/dummy
$ rails landlord:fetch_stripe_plans
$ rails s
Navigate to http://localhost:3000/new to create a new account
Notes:
- You may want to run a local mail server such as https://mailcatcher.me/ to receive signup emails
- Your local dev server must be publicly accessible in order to use Google OAuth
- Your local dev server must be publicly accessible in order to receive Stripe billing webhooks
Add this line to your application's Gemfile:
gem 'landlord'
gem 'figaro'
And then execute:
$ bundle install
$ bundle exec figaro install
Setup Google OAuth2: https://github.com/zquestz/omniauth-google-oauth2
Add your Google API keys to config/application.yml
Add your Stripe API keys to config/application.yml
(Note: if you wish to store your API keys elsewhere, you can safely delete config/application.yml
and remove the figaro gem.)
Then execute:
$ rails landlord:install:migrations
$ rails db:setup
$ rails landlord:fetch_stripe_plans
Copy app/views/devise
and app/views/landlord
from the Landlord gem directory to your application's app/views
directory
- Expand Pundit authorization policies
- Expand test coverage
- Add dynamic role management
- Streamline installation process
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.