Git Product home page Git Product logo

shirjeel-alam / multi-tenancy-devise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bradpotts/multi-tenancy-devise

0.0 2.0 0.0 18.31 MB

mtdevise gem adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.

Home Page: http://phcnetworks.net

License: MIT License

Ruby 74.13% JavaScript 1.87% CSS 2.73% HTML 21.27%

multi-tenancy-devise's Introduction

security Code Climate Coverage Status Build Status Gem Version

Mtdevise (MultiTenancyDevise) Documentation

PHC mtdevise gem adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Twitter Bootstrap Devise views included.

  • Multi-tenancy using subdomain scoping and account_id column.
  • Adds basecamp style logins to devise authentication gem.
  • Highly customizable views and layouts using standard bootstrap 3 code.
  • Central login screen for all tenants (users) or logins through subdomain.
  • Compatible with postgre, mysql and sqlite (for deve environments)

Step 1 - Add user model to your app (Must be Done First!!)

Generate a user.rb file in your mainapp and add the code below

rails g model User  
include Mtdevise::UserStorage  

Step 2 - Add Mtdevise to your gemfile

gem 'mtdevise', '~> 1.5'  
bundle exec install  

Step 3 - Add and migrate mtdevise database tables

rake railties:install:migrations  
rake db:migrate  

Step 4 - Configure ActionMailer

  • Mailer functions are required in order for mtdevise to operate.
  • Mailer is used for confirmation and password reset functions.

Step 5 - Mount the Engine in your Routes File

Add this line at the end of the routes file.

mount Mtdevise::Engine, :at => '/'

Step 6 - Constrain the routs you want secured

All the routes you want to have multi-tenacy login functions goes in between the constraints block.

constraints(Mtdevise::Constraints::SubdomainRequired) do  
	# Routes Requiring Security & Multi-Tenancy Routes    
end  

Step 7 - Modifications to MainApp Controllers & Database

Your app needs modification to controllers (example) and corresponding database tables must have an accounts_id column.

accounts_id  

Step 8 - Add mtdevise extension to models

Add the mtdevise extension to the top of all models for the routes configured in the previous step.

def self.scoped_to(account)  
	where(:account_id => account.id)  
end  

Step 9 - Configure scopes in your controller

Scope your controllers. Examples on github wiki or multi-tenant starter app.

.scoped_to(current_account)  

Additional Information

Views - Mtdevise Views Can be Customized

Once installed views can be generated and customized to your apps needs.

rails generate mtdevise:views  

Having troubles ?

Multi-Tenant Starter App
Documentation (Github Wiki)
Issues & Bug Reports
Managed by PHCNetworks

multi-tenancy-devise's People

Contributors

shirjeel-alam avatar

Watchers

James Cloos avatar  avatar

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.