Paginating 3 arrays of 3 differnet model

Hi
I have there arrays i get like below in controller
@hardware_cis=HardwareCi.find_where(:all)
@software_cis=SoftwareCi.find_where(:all)
@document_cis= documentCi.find_where(:all)
The above I have to rearrange to get the pagination
The above as a whole i have to paginate .For example @hardware_cis
may contain some 10 items @software_cis may contain 6 items and the
other some 12 items…And i have to paginate total 15 items per page like
5 from each…And in the view I am iterating through each three like

<% for document_ci in @document_cis %>
code—

<% for software_ci in @software_cis %>
code–

<% for hardware_ci in @hardware_cis %>

I treid like
@hardware_cis=HardwareCi.paginate
per_page=>5,:page=>params[:hardware_page]
@software_cis=SoftwareCi.paginate
per_page=>5,:page=>params[:software_page]
@document_cis=DocumentCi.paginate
per_page=>5,:page=>params[:document_page]

But this is not the way I think .Here i have three seperate pagination
in view.That is not i want.How can I solve this?Please help

Thanks in advance
Sijo

0-0-0-0-0-0-0-0-0-0-0
Think Fool : Method 1
0-0-0-0-0-0-0-0-0-0-0

@hardware_cis=HardwareCi.find(:all)

@all_data = [HardwareCi.find(:all), SoftwareCi.find(:all),
DocumentCi.find(:all)]

@pages, @users = paginate_collection @all_data, :page => @params[:page]

private

#you can modify it
def paginate_collection(collection, options = {})
default_options = {:per_page => 10, :page => 1}
options = default_options.merge options
pages = Paginator.new self, collection.size, options[:per_page],
options[:page]
first = pages.current.offset
last = [first + options[:per_page], collection.size].min
slice = collection[first…last]
return [pages, slice]
end

x-x-x-x-x-x-x-x-x-x-x
Think Fool : Method 2
x-x-x-x-x-x-x-x-x-x-x

@hardware_cis=HardwareCi.paginate
per_page=>5,:page=>params[:hardware_page]
@software_cis=SoftwareCi.paginate
per_page=>5,:page=>params[:software_page]
@document_cis=DocumentCi.paginate
per_page=>5,:page=>params[:document_page]

@all_data = []
@all_data << @hardware_cis
@all_data << @software_cis
@all_data << @document_cis

<% for data in @all_data %>

Reinhart
http://teapoci.blogspot.com

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