1

マルチテナント Rails アプリがあります。

各モデルで次のコード行を使用します。

default_scope { where(tenant_id: Tenant.current_id) }

というモデルがworequestあり、 という整数列が含まれていますrequest_closedstatuscodeどのテナントが閉鎖されているかを各テナントに定義してもらいたいと思います。

ステートメントの後、default_scopeクローズされていないリクエストのスコープを設定しようとしています。

私は次のことを試しましたが、うまくいきません:

scope :closed, where(:statuscode_id => Tenant.current.request_closed)
scope :closed, where(:statuscode_id => current_tenant.request_closed)
scope :closed, where(:statuscode_id => Tenant.request_closed)
scope :closed, where(:statuscode_id => Tenant.current_id.request_closed)

私がやりたいことをすることは可能ですか?

助けてくれてありがとう!

4

1 に答える 1

0

の属性request_closedTenantあるため、値を使用して現在のテナントを取得し、current_idそれを呼び出す必要があります。

Tenant.find(Tenant.current_id).request_closed
于 2013-08-13T16:06:44.373 に答える