Skip to content

Instantly share code, notes, and snippets.

@tonibergholm
Forked from dhh/gist:45076
Created January 9, 2009 10:59
Show Gist options
  • Select an option

  • Save tonibergholm/45083 to your computer and use it in GitHub Desktop.

Select an option

Save tonibergholm/45083 to your computer and use it in GitHub Desktop.

Revisions

  1. dhh revised this gist Jan 9, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # 2) Setup an Apache vhost to catch the star pointer:
    #
    # <VirtualHost *:80>
    # ServerName www.example.com
    # ServerName example.com
    # ServerAlias *.example.com
    # </VirtualHost>
    #
  2. dhh revised this gist Jan 9, 2009. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,8 @@
    # 2) Setup an Apache vhost to catch the star pointer:
    #
    # <VirtualHost *:80>
    # ServerName *.example.com
    # ServerName www.example.com
    # ServerAlias *.example.com
    # </VirtualHost>
    #
    # 3) Set the current account from the subdomain
    @@ -12,7 +13,7 @@ class ApplicationController < ActionController::Base

    private
    def set_current_account
    @current_account = Account.find_by_subdomain(request.subdomains.first)
    @current_account = Account.find_by_subdomain!(request.subdomains.first)
    end
    end

  3. @invalid-email-address Anonymous created this gist Jan 7, 2009.
    24 changes: 24 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # 1) Point *.example.com in your DNS setup to your server.
    #
    # 2) Setup an Apache vhost to catch the star pointer:
    #
    # <VirtualHost *:80>
    # ServerName *.example.com
    # </VirtualHost>
    #
    # 3) Set the current account from the subdomain
    class ApplicationController < ActionController::Base
    before_filter :set_current_account

    private
    def set_current_account
    @current_account = Account.find_by_subdomain(request.subdomains.first)
    end
    end

    # 4) Tie all top-level requests off the current account
    class CustomersController < ApplicationController
    def index
    @customers = @current_account.customers
    end
    end