0

有没有人有同样的问题或有效的解决方案?我总是收到这个错误消息,这里是模型、控制器和视图代码

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" %>

请帮助,在此先感谢

4

1 回答 1

0

您收到此错误是因为应该传递给will_paginate视图辅助方法的第一个参数是您要分页的集合:

<%= will_paginate @profiles %>

——而 searchlogic 的order辅助方法返回的是一个链接,而不是一个集合。你可能想要这样做:

<%= order @profiles, :by => :created_at, :as => 'name' %>
<%= will_paginate @profiles %>

我不确定它是否会按预期工作,我还没有尝试过。

于 2010-07-07T13:50:21.693 回答