【发布时间】:2016-04-09 07:20:22
【问题描述】:
我有一个多租户应用程序(rails 后端),我需要将与租户无关的预填充项目列表与租户特定属性混合在一起。
想知道我是否有人使用过委托来完成这项工作,并且与从 Postgres 冒险进入 MongoDB 相比,性能还不错
示例模型:
Class EquipmentList < ActiveRecord::Base
attr_accessible :name, :category_id
has_one :tenant_equipment_list
delegate :alt_name, to: tenant_equipment_list
end
Class TenantEquipmentList < ActiveRecord::Base
attr_accessible :alt_name, :group, :sku, :est_price, :equipment_list_id
belongs_to :equipment_list
default_scope { where(tenant_id: Tenant.current_id) }
end
【问题讨论】:
-
更新:一直在一个低流量的网站上做这个,到目前为止还没有发现任何问题。
标签: ruby-on-rails ruby postgresql multi-tenant