Topic: Paginate

Hi everyone.

Would anyone know how to use paginate with a collection that I have already loaded.

I am versioning a table using the plugin acts_as_versioned and this provides me with the ability to retreive all versions of a single entry

so something like

@versions_of_entry = Entry.find_versions params[:id] 
# using same options as find will return an
# array all version of entry with id params[:id]

Now Im trying to slot this in nicely with the other code I have.  This is using paginate to obtain all the current (latest version) Entries.

# Im trying to achieve something like this
@versions_of_entry, paginator = paginate( Entry.find_versions params[:id] )
# but paginate takes the options of find (and not an existing collection)

So the question.  How/Can I use paginate to paginate a pre-loaded Collection?

Re: Paginate

Try using custom/classic pagination:

  @entries_pages = Paginator.new self, Entry.count, 10, @params['page']
  @versions_of_entry = Entry.find_versions params[:id]

vinnie - rails forum admin

Re: Paginate

Thanks Vin that seems to have worked a charm (as im getting a new error).  Now to just solve a problem between 2 plugins smile