gist: 44410 Download_button fork
public
Public Clone URL: git://gist.github.com/44410.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

Owner

Anonymous

Forks

gist: 44413 by shanesv...   Basecamp-style subdomains w...
gist: 44415 by NewMonarch   Improved! A slight alterati...
gist: 44418 by jngo   Subdomains in Ruby on Rails
gist: 44419 by tbuser   Basecamp-style dynamic subd...
gist: 44433 by eddanger   Subdomains in Ruby on Rails
gist: 44547 by xilo32   Basecamp-style Subdomain Ac...
gist: 44638 by ariejan   Rails subdomain support (fo...
gist: 60969 by satynos   resources_controller - Subd...

Revisions

  • 4cc1d2 Wed Jan 07 12:41:52 -0800 2009