2014-02-12 3 views
0

나는 Acts_as_tenant을 사용하고 있습니다. 의사가 "adds a handy helper to your controllers current_tenant, containing the current tenant object"라고 말합니다.레일즈는 컨트롤러에서 current_tenant를 사용하여 세입자 오류로 작동합니다.

하지만 모델의 현재 거주자에게 문의하고 싶습니다. Tenant 모델에는 request_closed 열이 포함되어 있습니다.

undefined local variable or method `current_tenant' 

모델에 current_tenant에 액세스 할 수있는 방법이 있나요 : 내가 얻을

closedcode = ActsAsTenant.current_tenant.request_closed 
and 
closedcode = self.tenant.request_closed 

을하지만 : 나는 또한 시도

class Worequest < ActiveRecord::Base 
    acts_as_tenant(:tenant) 
    closedcode = current_tenant.request_closed 
    scope :notclosed, where("statuscode_id < ?", closedcode) 

:

나는이 일을하고자하는 ?

도움 주셔서 감사합니다. 내 Heroku가 준비 서버에 개발을 수행하지만 -

갱신 1

나는이 일 거라 생각 했어요.

응용 프로그램 컨트롤러 :

class ApplicationController < ActionController::Base 

    protect_from_forgery 

    set_current_tenant_by_subdomain(:tenant, :subdomain) 

    before_filter :set_tenant_codes 
    def set_tenant_codes 
     $requestclosed = current_tenant.request_closed 
    end 

요청 컨트롤러 :

scope :notclosed, where("statuscode_id < ?", $requestclosed) 

????

답변

0

이 일 :

def self.closed 
    where("statuscode_id = ?", ActsAsTenant.current_tenant.request_closed) 
    end