0

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

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 に答える