yml rails中的继承?

时间:2016-03-02 08:57:09

标签: ruby-on-rails yaml

我有一个yml文件,就像这样我写了所有的角色 角色标签。

admin标记继承了角色的所有属性,但我希望defalut标记只能继承role_5。怎么做??

 roles: &all
 role_1: "edit"
 role_2: "create"
 role_3: "read"
 role_4: "update"
 role_5: "writepost"

 admin: 
 <<: *all #inherits all 


 default : 
  <<:only inherit role_5 # what should i write ???

1 个答案:

答案 0 :(得分:1)

像这样:

roles: &all
 role_1: "edit"
 role_2: "create"
 role_3: "read"
 role_4: "update"
 role_5: &role_5
   "writepost"

 admin: 
 <<: *all #inherits all 


 default: *role_5