Rails searchlogic 和 will_paginate 未定义方法“order”对于 #
有人有同样的问题或有效的解决方案吗? 我总是收到此错误消息,这里是模型、控制器和视图代码,
class Profile < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 10
end
def index
@search = Profile.search(params[:search])
@profiles = @search.paginate(:page => params[:page])
end
<%= will_paginate order @profiles , :by => :created_at, :as => "name" %>
请帮忙,提前致谢
Does anyone have the same problem or a working solution?
I get always this error message, here are model, controller and view code
class Profile < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 10
end
def index
@search = Profile.search(params[:search])
@profiles = @search.paginate(:page => params[:page])
end
<%= will_paginate order @profiles , :by => :created_at, :as => "name" %>
please help, thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到此错误是因为应传递给
will_paginate
视图辅助方法的第一个参数是您要分页的集合:— 而 searchlogic 的
order
辅助方法返回一个链接,不是一个集合。您可能想这样做:我不确定它是否会按预期工作,我还没有尝试过。
You are getting this error because the first parameter that should be passed to the
will_paginate
view helper method is the collection you want to paginate:—whereas searchlogic's
order
helper method returns a link, not a collection. You probably want to do this:I'm not sure if it will work as intended, I haven't tried it.