Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (30 sloc) 1.599 kb
ffef6c3f »
2009-01-09 Add subdomain_account_options cattr_accessor to store options
1 subdomain\_account
2 ==================
cf98c48d »
2008-06-05 Initial import from access_control_list repository
3
ac9adb57 »
2009-01-09 Gemify
4 A rails gem/plugin that handles subdomain accounts
cf98c48d »
2008-06-05 Initial import from access_control_list repository
5
6
7 Installation
8 ------------
9
ac9adb57 »
2009-01-09 Gemify
10 gem install shuber-subdomain_account --source http://gems.github.com
11 OR
cf98c48d »
2008-06-05 Initial import from access_control_list repository
12 script/plugin install git://github.com/shuber/subdomain_account.git
13
14
ffef6c3f »
2009-01-09 Add subdomain_account_options cattr_accessor to store options
15 Usage
16 -----
17
18 Simply add `before_filter :subdomain_account_required` for any actions that require a subdomain. A `:model` will then be searched
19 by `:field` for the current subdomain. The result of that query is stored in a controller instance method called `current_account`.
20 In the example below, the `current_account` would be set to the result of `Account.find_by_subdomain(request.subdomains.first)`.
21 The `:model` and `:field` options are customizable, see below.
cf98c48d »
2008-06-05 Initial import from access_control_list repository
22
9f8ce95e »
2008-06-05 Updated README
23 class ProjectsController < ApplicationController
a55f3eac »
2008-06-05 Updated README
24 before_filter :subdomain_account_required
ffef6c3f »
2009-01-09 Add subdomain_account_options cattr_accessor to store options
25
a55f3eac »
2008-06-05 Updated README
26 def index
27 render :text => current_account.subdomain
28 end
9f8ce95e »
2008-06-05 Updated README
29 end
cf98c48d »
2008-06-05 Initial import from access_control_list repository
30
ffef6c3f »
2009-01-09 Add subdomain_account_options cattr_accessor to store options
31 By default the `:model` to use for looking up records is `Account` and the `:field` to search by is `:subdomain`. You can change
32 this by modifying the controller's `subdomain_account_options` attribute like so:
cf98c48d »
2008-06-05 Initial import from access_control_list repository
33
ffef6c3f »
2009-01-09 Add subdomain_account_options cattr_accessor to store options
34 class ApplicationController < ActionController::Base
35 self.subdomain_account_options.merge!(:model => Company, :field => :username)
36 end
37
e4a49a81 »
2009-01-09 Update README
38 When a subdomain is required but the `current_account` was not found, the controller calls the `subdomain_account_not_found` instance
39 method which simply renders a 404. You can overwrite this method to change this behavior.
9f8ce95e »
2008-06-05 Updated README
40
41
cf98c48d »
2008-06-05 Initial import from access_control_list repository
42 Contact
43 -------
44
45 Problems, comments, and suggestions all welcome: [shuber@huberry.com](mailto:shuber@huberry.com)
Something went wrong with that request. Please try again.