閱讀更多關於資源定製,你可以覆蓋scoped_collection像
ActiveAdmin.register Report do
menu parent: 'Administration', priority: 2
controller do
def scoped_collection
Report.includes(:users, ....)
end
end
end
UPD,完全同意@TimoSchilling的評論。
如果你想覆蓋scoped_collection
使用super
然後追加方法,這樣,InheritedResource的end_of_association_chain
不會被忽略。
所以最後的代碼是
ActiveAdmin.register Report do
menu parent: 'Administration', priority: 2
controller do
def scoped_collection
super.includes(:users, ....)
# or
super.eager_load(:users, ....)
end
end
end
然而,在大多數情況下,所有這https://stackoverflow.com/a/29038410/246544#29038410答案將工作的偉大。
這種方式的作品,但你應該使用'超'而不是'報告',否則你會失去像auth或過濾的東西。 – 2015-03-16 08:46:14
@TemoSchilling,只有繼承的資源特性纔會被放棄,在''''''''''''''''''''''scoped_collection'''後面的'''find_collection''中附加了AA特性。 – Fivell 2015-03-16 17:07:41