multi-tenant and use of ruby delegate vs NoSQL for tenant context -
i have multi-tenant app (rails backend) , need mix tenant-agnostic pre-populated list of items tenant specific attributes.
was wondering if has used delegate done , had ok performance vs. venturing out of postgres mongodb
example models:
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
i've run on low traffic site. rails end handles pretty in outputting json.
realized better use tenant version foreign key , delegate master attributes tenant. looks this:
class equipmentlist < activerecord::base attr_accessible :name, :category_id has_one :tenant_equipment_list end class tenantequipmentlist < activerecord::base attr_accessible :alt_name, :group, :sku, :est_price, :equipment_list_id belongs_to :equipment_list delegate :name, to: tenant_equipment_list #prefix: true if want default_scope { where(tenant_id: tenant.current_id) } end
Comments
Post a Comment