Skip to content

Instantly share code, notes, and snippets.

@seven1m
Created October 19, 2010 21:48
Show Gist options
  • Save seven1m/635207 to your computer and use it in GitHub Desktop.
Save seven1m/635207 to your computer and use it in GitHub Desktop.
class Person < ActiveRecord::Base
cattr_accessor :current_site_id
default_scope lambda { where(:site_id => Person.current_site_id) }
end
Person.current_site_id = 1
Person.all
# => SELECT "people".* FROM "people" WHERE ("people"."site_id" = 1)
Person.current_site_id = 2
Person.all
# => SELECT "people".* FROM "people" WHERE ("people"."site_id" = 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment