マルチテナント Rails アプリがあります。
各モデルで次のコード行を使用します。
default_scope { where(tenant_id: Tenant.current_id) }
というモデルがworequest
あり、 という整数列が含まれていますrequest_closed
。statuscode
どのテナントが閉鎖されているかを各テナントに定義してもらいたいと思います。
ステートメントの後、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)
私がやりたいことをすることは可能ですか?
助けてくれてありがとう!