Tragically L33T
msgbartop
Hip? Who talks like that?
msgbarbottom

07 Jun 06 Using Subdomains as Account Keys

I looked all over for an explanation on how to use the domain or subdomain as the account key (a la campfirenow.com) and now I have it…

All it takes is putting the following in the application controller.


attr_writer :account
attr_reader :account
before_filter {|c|
  c.account = Account.find_by_subdomain(
    c.request.subdomains.first
  )
}

Then you can use it in any controller as follows:


class BlogController < ActionController::Base
  def index
    render_text account.subdomain
  end
end

Check it out here

[tags]rails, ruby on rails, programming[/tags]



Leave a Comment