新手问题 请教,有没有 Gem 可以把单表继承特殊属性保存到 key-value 表,然后 model.attr 得到该属性

zmcnotafraid · October 17, 2016 · Last by pynix replied at October 21, 2016 · 1396 hits

过程:model A,model B 单表继承自 C,A 和 B 的特定属性目前看来不明确,所以我不能把这些属性加在 C 表中,而是新建一张 key-value 表,把这些特定属性存放在这个表中。我目前认为只能通过 A.where("key = attr").first.value 得到属性值,有点繁琐,所以请教下大家有没有可以让我直接 A.attr 得到属性值得 gem。

你把这个查询语句写成一个 c 的方法 不就可以了

zmcnotafraid closed this topic. 16 Jan 11:03
You need to Sign in before reply, if you don't have an account, please Sign up first.