简体   繁体   English

activeadmin-mongoid:如何根据ID进行过滤?

[英]activeadmin-mongoid: How to filter on id?

This doesn't work: 这不起作用:

filter :name, :as => :string

Because mongoid ids are not strings, you can't filter on the ids as a string. 由于mongoid ID不是字符串,因此您不能将ID作为字符串进行过滤。 Is there a nice way to filter on the ids by creating a custom filter type? 是否有一种很好的方法通过创建自定义过滤器类型来过滤ID?

Found a way - I'm not sure exactly why it works yet, but: 找到了一种方法-我不确定为什么它仍然有效,但是:

filter :device_id, :as => :numeric

does the trick. 绝招。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM