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

tabaluga
  • 1,377
  • 4
  • 20
  • 27

1 Answers1

0

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:

<%= will_paginate @profiles %>

—whereas searchlogic's order helper method returns a link, not a collection. You probably want to do this:

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

I'm not sure if it will work as intended, I haven't tried it.

John Topley
  • 113,588
  • 46
  • 195
  • 237
  • oh, thanks for the quick answer. I want to use the order method from searchlogic in the view. How can I do that in combination with will_paginate ? – tabaluga Jul 07 '10 at 13:55
  • Hey, I got it! Thanks for pointing me in the right direction! <%= will_paginate @profiles %> <%= order @search, :by => :created_at %> Upps, didn't press the refresh button. Thankyou, thankyou, thankyou – tabaluga Jul 07 '10 at 14:01
  • can this be moved into the controller? – bennett_an Nov 23 '11 at 16:53