Skip to content

Instantly share code, notes, and snippets.

@rx
Created January 1, 2010 19:55
Show Gist options
  • Save rx/267230 to your computer and use it in GitHub Desktop.
Save rx/267230 to your computer and use it in GitHub Desktop.
Multitenent presentation
http://aac2009.confreaks.com/videos/06-feb-2009-14-30-writing-multi-tenant-applications-in-rails-guy-naor-small.mp4
Skip ahead to 22:55
Here is my retype of the application control logic to switch schemas using search paths in postgresql.
class ApplicationController < ActionController::Base
before_filter :set_account
after_filter :clear_account
protected
def set_account
SchemaUtils.add_schema_to_path
Account.find_by_subdomain(request.subdomains.last).db_schema
end
def clear_account
SchemaUtils.reset_search_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment