{"id":15467793,"url":"https://github.com/bradpotts/multi-tenancy-devise","last_synced_at":"2025-12-16T16:31:49.418Z","repository":{"id":33135685,"uuid":"36775282","full_name":"bradpotts/multi-tenancy-devise","owner":"bradpotts","description":"mtdevise adds basecamp style user logins to your ruby on rails application.","archived":false,"fork":false,"pushed_at":"2022-04-11T22:37:45.000Z","size":19078,"stargazers_count":30,"open_issues_count":13,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T12:06:30.153Z","etag":null,"topics":["authentication","bradpotts","engine","gem","multi-tenancy","multi-tenant","phcnetworks","rails","rails-engine","ruby-gem","subdomain","tenants"],"latest_commit_sha":null,"homepage":"https://phcnetworks.net","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradpotts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-03T02:35:10.000Z","updated_at":"2024-11-13T01:25:41.000Z","dependencies_parsed_at":"2022-08-20T13:10:45.763Z","dependency_job_id":null,"html_url":"https://github.com/bradpotts/multi-tenancy-devise","commit_stats":null,"previous_names":["phcnetworks/multi-tenancy-devise"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradpotts%2Fmulti-tenancy-devise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradpotts%2Fmulti-tenancy-devise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradpotts%2Fmulti-tenancy-devise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradpotts%2Fmulti-tenancy-devise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradpotts","download_url":"https://codeload.github.com/bradpotts/multi-tenancy-devise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251311330,"owners_count":21569009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","bradpotts","engine","gem","multi-tenancy","multi-tenant","phcnetworks","rails","rails-engine","ruby-gem","subdomain","tenants"],"created_at":"2024-10-02T01:26:30.393Z","updated_at":"2025-12-16T16:31:44.381Z","avatar_url":"https://github.com/bradpotts.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![security](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master.svg)](https://hakiri.io/github/PHCNetworks/multi-tenancy-devise/master)\n[![Code Climate](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise/badges/gpa.svg)](https://codeclimate.com/github/PHCNetworks/multi-tenancy-devise)\n[![Gem Version](https://badge.fury.io/rb/mtdevise.svg)](https://badge.fury.io/rb/mtdevise)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PHCNetworks/multi-tenancy-devise/blob/master/MIT-LICENSE)\n\n### MTDevise Rails 5.1 Multi-Tenancy Engine Documentation  \nPHC MTDevise Rails 5.1 engine adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.  \n\n* Multi-tenancy using subdomain scoping and account_id column.  \n* Adds basecamp style logins to devise authentication gem.  \n* Welcome, Dashboard with custom Devise views included.  \n* Highly customizable views and layouts using standard bootstrap 3 code.  \n* Central login screen for all tenants (users) or logins through a subdomain.  \n* Mis-Spelling and redirect to welcome screen if subdomain none-existent.  \n* Compatible with postgre, mysql and sqlite (for dev environments).  \n\n#### Step 1 - Add user model to your app (Must be Done First!!)\nGenerate a user.rb file in your mainapp and add the code below\n\n\trails g model User\n\tinclude Mtdevise::UserStorage\n\n#### Step 2 - Add Mtdevise to your gemfile and run command  \n\n\tgem 'mtdevise', '~\u003e 16.0'\n\tbundle exec install\n\n#### Step 3 - Add and migrate mtdevise database tables\n\n\trake railties:install:migrations\n\trake db:migrate\n\n#### Step 4 - Configure ActionMailer\n* Mailer functions are required in order for mtdevise to operate.\n* Mailer is used for confirmation and password reset functions.\n\n#### Step 5 - Mount the Engine in your Routes File\nAdd this line at the end of the routes file.  \n\n\tmount Mtdevise::Engine, :at =\u003e '/'\n\n#### Step 6 - Constrain the routs you want secured\nAll the routes you want to have multi-tenacy login functions goes in between the constraints block.\n\n\tconstraints(Mtdevise::Constraints::SubdomainRequired) do\n\t\t# Routes Requiring Security \u0026 Multi-Tenancy Routes  \n\tend\n\n#### Step 7 - Modifications to MainApp Controllers \u0026 Database  \nYour app needs modification to [controllers (example)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Scoped-Controller-Example)  \nAny corresponding db database tables must have an accounts_id column\n\n\taccounts_id\n\n#### Step 8 - Add mtdevise extension to models  \nAdd the mtdevise extension to the top of all models for the routes configured in the previous step.  \n\n\tdef self.scoped_to(account)\n\t\twhere(:account_id =\u003e account.id)\n\tend\n\n#### Step 9 - Configure scopes in your controller\nScope your controllers. Examples on github wiki or multi-tenant starter app.\n\n\t.scoped_to(current_account)\n\n#### Step 10 - Environment (ENV) Variables\nSet a sent from email address for confirmation and password reset emails [more info here.](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables)  .  \n\n\tPHC_MTDEVISE_SENDER = no_reply@example.com\n\n### Additional Information  \n\n#### Views - Mtdevise Views Can be Customized  \nOnce installed views can be generated and customized to your apps needs.  \n\n\trails generate mtdevise:views\n\trake assets:clobber\n\trake assets:precompile\n\n#### Additional Documentation  \n[Multi-Tenant Starter App](https://github.com/PHCNetworks/multi-tenancy-starter-devise)  \n[Documentation (Github Wiki)](https://github.com/PHCNetworks/multi-tenancy-devise/wiki)  \n[Environment Variables](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/ENV---Environment-Variables)  \n[Issues \u0026 Bug Reports](https://github.com/PHCNetworks/multi-tenancy-devise/issues)  \n[Past Security Patch Notes](https://github.com/PHCNetworks/multi-tenancy-devise/wiki/Critical-Security-Updates)  \n[Managed by PHCNetworks](http://phcnetworks.net)  \n\n[![Circle CI](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master.svg?style=svg)](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradpotts%2Fmulti-tenancy-devise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradpotts%2Fmulti-tenancy-devise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradpotts%2Fmulti-tenancy-devise/lists"}