Will_paginate not from model, in array?

Hi:

I’ve got an array i’d like to paginate. It’s a collection of the same
model, but I can’t seem to paginate accordingly. Here’s my code:

<%pics = PictureCategory.find_goal_pics(uid)
pics = pics.paginate
pics.each do |p| %>


<%= image_tag(p.public_filename(:small), :alt => “goal
picture”, :class => “goalpic”)%>

<%= p.picture_category.name %>

<% end %>
<% end %>

<%= will_paginate pics %>

But there’s no pagination on the page, similarly I tried:

pics = pics.paginate(:all, :per_page => 8)

which didn’t work either. I’m sure I don’t understand enough about
will_paginate. You help is as always greatly appreciated.

Mike

This is the we got the output:

@docket_types = DocketType.paginate :page => params[:page], :per_page
=> 5, :conditions => [“court_id in (#{@current_user.court_ids.join(’,
')})”]

<%= will_paginate @docket_types %>

So I’m still having problmes, having just discovered that even though
pagination correctly splits up my page, when you click on a page link,
it doesn’t actually work! :frowning:

My problem is that the array I compile is actually a combination of a
few different type of models. What do I do in this case (notice the
hack at the end):

def index
@goals = Search.search_goals(params[:search])
@people = Search.search_people(params[:search])
@all = []
#mark goals and people and teams for easier presentation processing
(has to do with the way I display in the view)
@goals.each do |g|
@all << [“g”,g]
end
@people.each do |p|
@all << [“p”,p]
end
#here’s the pagination hack
all_temp = @all
@all = all_temp.paginate

end

note that:

@all = all_temp.paginate(:all, :page => params[:page], :per_page => 10)
gives the error:

undefined method `to_i’ for {:per_page=>10}:Hash

Any help you can give would be greatly appreciated!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs