如何在 Rails 3 的 metawhere 中搜索关联?
当我使用 searchlogic 时,我可以使用以下内容:
27 # @todos = Todo.contact_user_id_is(current_user).
28 # contact_campaign_id_is(@campaign).
29 # current_date_lte(Date.today).
30 # done_date_null.
31 # ascend_by_contact_id.
32 # ascend_by_current_date
例如,它允许我搜索属于 Todo 记录的联系人的营销活动。
这是我尝试过的(不知道如何进行排序:
22 @todos = Todo.joins(:contacts).where(:user_id.eq => current_user,
23 :contacts => { :campaign_id.eq => @campaign.id},
24 :current_date.lteq => Date.today,
25 :done_date.not_eq => nil)
How do I do like that with metawhere?
When I was using searchlogic, I couuld use the following:
27 # @todos = Todo.contact_user_id_is(current_user).
28 # contact_campaign_id_is(@campaign).
29 # current_date_lte(Date.today).
30 # done_date_null.
31 # ascend_by_contact_id.
32 # ascend_by_current_date
For example, it would allow me to search for the campaign belong to a contact that belonged to the Todo record.
This is what I've tried (not sure how to do the sorting:
22 @todos = Todo.joins(:contacts).where(:user_id.eq => current_user,
23 :contacts => { :campaign_id.eq => @campaign.id},
24 :current_date.lteq => Date.today,
25 :done_date.not_eq => nil)
How do I do something like that with metawhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 Todooes_to 或 has_one 联系人(我假设是基于上面的 Searchlogic 查询的情况),您可能需要执行类似的操作(未经测试):
If Todo belongs_to or has_one contact, which I'm assuming is the case based on the Searchlogic query above, you would want to do something like (untested):