如何使用thinktank和indextank索引关联模型
我们正在使用 Thinktank gem,但在索引模型关联(即使是简单的关联)时遇到了麻烦。例如,一个配置文件属于一个机构,该机构有一个名称 - 我们想做类似的事情:
class Profile < ActiveRecord::Base
#model associations
define_index do
indexes institution(:name), :as => :institution_name
end
end
但这不起作用。这一定很简单——我做错了什么?
We are using thinkingtank gem and having trouble indexing model associations, even simple ones. For example, a profile belongs to an institution, which has a name – we would like to do something like:
class Profile < ActiveRecord::Base
#model associations
define_index do
indexes institution(:name), :as => :institution_name
end
end
but that doesn't work. This must be very simple – what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题的一个可能的解决方案是添加一个将元素返回到索引的方法。对于 profile.institution.name 情况:
thinktank 也不支持“, :as => ...”语法。
我还建议尝试一下 Tanker: https://github.com/kidpollo/tanker
问候。
阿德里安
a possible solution to this issue would be adding a method returning the element to index. For the profile.institution.name case:
Also the ", :as => ..." syntax is not supported on thinkingtank.
I would also recommend giving a try to Tanker: https://github.com/kidpollo/tanker
Regards.
Adrian