You may store current manager in Manager model in before filter:
def load_manager
Manager.set_current(request.subdomain)
end
class Manager < ActiveRecord::Base
cattr_accessor :current
def self.set_current(subdomain)
self.current = self.find_by_subdomain(subdomain)
end
end
class Lot < ActiveRecord::Base
default_scope { Manager.current.present? ? where(deleted: false).joins(:auction => :manager).where("auctions.manager_id = ?", Manager.current.id) : where(deleted: false) }
end
Update
As @Mik_Die noticed it is not thread safe, for thread safe solution a reader may look at railscasts - multitenancy-with-scopes (code here). There we just store current_id in Thread
.