我有一個奇怪的問題,我ActiveAdmin資源:軌道4 ActiveAdmin - 未定義的局部變量或方法`collection_before_scope」
ActiveAdmin.register ServicePage do
menu priority: 5
permit_params :title, :body, :slug, :published
config.sort_order = 'created_at_desc'
config.per_page = 10
scope :all, default: true
scope :published
scope :not_published
filter :title
filter :slug
end
當我嘗試訪問索引頁吧,我得到undefined local variable or method 'collection_before_scope' for #<ActiveAdmin::Views::Scopes:0x007f4c8ecdfa28>
錯誤。
當我刪除那些3 scope
的,我得到Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.
但是,如果只有我更改代碼ActiveAdmin.register ServicePage, as: 'page' do
,一切似乎變得確定。我確信,當我剛剛將ServicePage資源添加到ActiveAdmin時,它工作正常。有人可以告訴我,發生了什麼事?
(紅寶石2.1.2,4.1.6的Rails,active_admin 1.0.0.pre)
ActiveAdmin(繼承的資源)會自動實例化與您的資源相對應的變量,這可能會導致像這樣的衝突。 – 2017-07-12 00:02:09