Ruby/Rails - Caminari没有通过破坏错误页面来定义

我不确定我的所作所为,但Caminari开始在我的申请中表现奇怪。

在我的控制器中:


@producers = Producer.order/:name/.page/params[:page]/


看法:


<%= paginate @producers %>


结果是:


undefined method `num_pages' for #<activerecord::relation:0x000001026e6308>


如果我添加 .per 在您的控制器中:


@producers = Producer.order/:name/.page/params[:page]/.per/25/


我得到了


undefined local variable or method `per' for #<activerecord::relation:0x0000010928ef60>


最后,如果我移动我的话,奇怪
.order/:name/

到最后,它有效:


@producers = Producer.page/params[:page]/.order/:name/


我假设其他一些 gem, 我安装了哪个,有一个行动领域
page

或导致问题的方法?

谢。
</activerecord::relation:0x0000010928ef60></activerecord::relation:0x000001026e6308>
已邀请:

窦买办

赞同来自:

好吧,只是猜到了。
我被安装了
http://activeadmin.info/
. 他安装了
will_paginate

作为依赖。

在最后一个提交中
Active Admin


will_paginate

被替换为
kaminari

.

我改变了我的 Gemfile, 拔出
Active Admin

的 github.
will_paginate

被删除了 bundle, 现在一切都有效。 您可以通过将下一行放入您的下一行来完成此操作 gemfile:


gem "activeadmin", git: "[url=https://github.com/gregbell/active_admin"]https://github.com/gregbell/active_admin"[/url]

小明明

赞同来自:

我对另一个人有同样的问题 gem, 谁要求 will_paginate. 使用此代码片段解决了该问题,从页面中取出 active_admin wiki:


if defined?/WillPaginate/
module WillPaginate
module ActiveRecord
module RelationMethods
def per/value = nil/ per_page/value/ end
def total_count// count end
end
end
module CollectionMethods
alias_method :num_pages, :total_pages
end
end
end


将它放在初始化程序中。

郭文康

赞同来自:

解决问题,开启
gem 'kaminari'

并删除
will_paginate

. 自从我已经使用过
will_paginate

, 我刚刚更新了当前的呼叫 will_paginate 为了 kaminari. 它们与实现非常相似,变化方面非常简单。

詹大官人

赞同来自:

我尝试了决定 johnnycakes, 但它继续给我仪表板上的堆叠级别太深 /相似地
https://github.com/gregbell/ac ... s/157
/

我发现的决定是表明这次审计:


gem 'activeadmin', :git => 'git://github.com/gregbell/active_admin.git', :ref => '811f286fda3b6dfa91aa'

要回复问题请先登录注册