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)
Generate a user.rb file in your mainapp and add the code below
rails g model User
include Mtdevise::UserStorage
gem 'mtdevise', '~> 1.5'
bundle exec install
rake railties:install:migrations
rake db:migrate
- Mailer functions are required in order for mtdevise to operate.
- Mailer is used for confirmation and password reset functions.
Add this line at the end of the routes file.
mount Mtdevise::Engine, :at => '/'
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
Your app needs modification to controllers (example) and corresponding database tables must have an accounts_id column.
accounts_id
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
Scope your controllers. Examples on github wiki or multi-tenant starter app.
.scoped_to(current_account)
Once installed views can be generated and customized to your apps needs.
rails generate mtdevise:views
Multi-Tenant Starter App
Documentation (Github Wiki)
Issues & Bug Reports
Managed by PHCNetworks