Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. class Person < ActiveRecord::Base
  2. cattr_accessor :current_site_id
  3. default_scope lambda { where(:site_id => Person.current_site_id) }
  4. end
  5.  
  6. Person.current_site_id = 1
  7. Person.all
  8. # => SELECT "people".* FROM "people" WHERE ("people"."site_id" = 1)
  9.  
  10. Person.current_site_id = 2
  11. Person.all
  12. # => SELECT "people".* FROM "people" WHERE ("people"."site_id" = 2)
Add Comment
Please, Sign In to add comment