Skip to content
Browse files

Bit of a rough readme regarding setting up an app to be subdomained.

  • Loading branch information...
1 parent 25240b6 commit ac0cbff3d51fd6c85263103db4ab069e5aae3348 @mconnell committed Jun 21, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 README.markdown
View
13 README.markdown
@@ -14,6 +14,8 @@ Alternatively as a git submodule:
git submodule add git://github.com/mconnell/multi_tenant.git vendor/plugins/multi_tenant
# How to Use
+
+## Models
Add `multi_tenant_model` to the primary model
class Account < ActiveRecord::Base
multi_tenant_model
@@ -40,4 +42,15 @@ If the current account is set, instantiating new property records will automatic
Property.new
#> <Property account_id: 25>
+## Controller
+If you want to have subdomained instances of the application:
+ class ApplicationController < ActionController::Base
+ subdomain_by_multi_tenant_model :account
+ end
+
+This basically tells the app to set the current account to Account.find_by_subdomain!(subdomain). Will Throw an exception if account can't be set. Every subdomain will also have an independent session.
+
+The controller aspect is currently not tested in isolating in the plugin as I haven't gotten around to working out how to generate routes in rails 3 for test controllers. They'll be extracted out of the application I'm using this plugin for eventually but you'll probably want to write some in your application..
+
+
Copyright (c) 2010 [Mark Connell], released under the MIT license

0 comments on commit ac0cbff

Please sign in to comment.
Something went wrong with that request. Please try again.