2015-11-24 24 views
1

我有積極的管理集成到我的應用程序。在「用戶」部分,過濾器的屬性太多,如果必須自定義過濾器中的條件,我必須重新編寫整個過濾器。有人可以建議我修改過濾器的特定條件,而不是重寫整個過濾器。我想修改附件中名稱列表的條件。活動管理定製過濾只有特定的屬性

喜歡這裏我要重新寫的過濾器的所有條件,而不是我想要更新特定過濾條件

filter :website_users 
    filter :identities 
    filter :names, :collection => proc {(Name.all).map{|c| [c.text, c.id]}} 
    filter :competitions 
    filter :suggested_names, :collection => proc {(Name.all).map{|c| [c.text, c.id]}} 

Filter with conditions

回答

3
preserve_default_filters! # build the default filters 
remove_filter :website_users # remove a default filter 
filter :names, collection: proc { Name.all.map{ |c| [c.text, c.id] } } 
+0

我想'集合: - > { Name.pluck(:text,:id)}'當涉及到大量數據時會更快,但它更像是OP的註釋:) –

+0

感謝Timo Schilling,您拯救了我的一天。 –

+0

如何刪除電子郵件過濾器包含,startswith,endswith,日期範圍? –

相關問題