Giter Club home page Giter Club logo

actsastenant-demo's Introduction

README

SaaS (organisations can have many members; organisation is billed)

haml devise simple_form https://github.com/scambra/devise_invitable

  1. Basic multitenant +
  • User can register in the application.+
  • User can create many tenants.+
  • When a user creates a tenant, he becomes a tenant member. +
  • User can see a list of tenants where he is a member (my_tenants scope).+
  • User can see only tenants where he is a member.-

1.1. Users

  • Users can exist without belonging to a member or a tenant. +
  • User table and user show pages exist. +

1.2. Tenants

  • All tenants scope +

1.2. devise_invitable - new user, new member +

  • User can invite other users to become members of a tenant via email. +
  • If a user with this email exists, we check if he is a member of this tenant. If he is not, he becomes a member. +
  • If a user with this email does not exist, he gets an invitation email via devise invitable + he becomes a member. +
  • #Note: devise_invitable has invitation on User model. If User accepts invitation once, he accepts all of them!

1.3. devise_invitable - new user, resend invitation +

  • If the user has not confirmed his email, he can be re-invited +

1.3. OPTIONAL: member of a tenant can exist without user?

  • devise_invitable - new user, old member ** A user can create a member without relation to another user in a tenant. ** A user can invite another user to use the member record via email.

1.4. subdomains

  • When creating a tenant, a user can type in a subdomain. +
  • Subdomains have restriction (permitted names, uniqueness). + A user can edit his subdomain. + If he does not type in a subdomain, a random one is assigned. When a user select..

1.2. acts_as_tenant Current_tenant is set by session/subdomain. Members are scoped by current_tenant. All models except User and Tenant are scoped by current_tenant.

Alternative Easy way (no subdomains)

  • add a tenant_id to user table.
  • when a user selects a tenant, his tenant_id is updated.
  • now, he sees views scoped by this tenant.
  1. Billing
  • rails g migration CreatePlans name:string price:integer billing_period:integer
  • Tenant belongs_to plan
  • #what if the app is modular and Tenant can select a lot of different billed features?
  • constraints {}
  1. Roles Roles are scoped by tenant. When a user creates a tenant, he becomes the tenant admin. Admin:
  • Invite / delete members.
  • Change member roles.
  • Access to billing.
  • Access to tenant settings. Moderator:
  • Everything except admin. Viewer:
  • Only view what moderator can do.
  1. ransack, public_activity, friendly_id

find tenant by subdomain https://medium.com/@praaveen/multi-tenancy-and-sub-domain-lvh-with-rails-f364c9dc0566

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.