使用者
------------------------------------------------------
| id | org_tag | email | org_handle |
------------------------------------------------------
| 1 | a | a@email.com | xyz |
------------------------------------------------------
| 2 | b | b@email.com | xxx |
------------------------------------------------------
| 1 | c | c@email.com | abc |
------------------------------------------------------
角色
------------------------------------------------
| id | store_id | user_id | position |
------------------------------------------------
| 1 | 1 | 1 | owner |
------------------------------------------------
| 2 | 1 | 2 | manager |
------------------------------------------------
| 1 | 2 | 2 | trial_editor |
------------------------------------------------
百货商店
-----------------------------------
| id | employees | org_handle |
-----------------------------------
| 1 | see json1 | abc |
-----------------------------------
| 2 | see json2 | xyz |
-----------------------------------
这个
[{'email':'a@em.com','role':'owner'},{'email':'b@em.com','role':'trial_editor'}]
产品
--------------------------------
| id | store_id | role_id |
--------------------------------
| 1 | 1 | 1 |
--------------------------------
| 2 | 2 | 2 |
--------------------------------
Organization has_many :users
User has_many :stores, through: roles
User has_many :role
User belongs_to :organization
Role belongs_to :user
Role belongs_to :store
Role has_many :products
Store has_many :users, through: roles
Store has_many :roles
Store has_many :products
Product belongs_to :store
Product belongs_to :role