【发布时间】:2011-09-01 15:18:40
【问题描述】:
我有很多动态代码将复杂的关系保存在字符串中。 例如:
"product.country.continent.planet.galaxy.name"
如何检查这些关系是否存在? 我想要一个类似下面的方法:
raise "n00b" unless Product.has_associations?("product.country.planet.galaxy")
我该如何实现呢?
【问题讨论】:
-
我想我们这里需要更多代码,你在字符串中存储了什么样的关联?活动记录关联?
标签: ruby-on-rails ruby activerecord metaprogramming