How to access any object in pagination

Hi,

Here I have code to display a list of products to display. I use
pagination to display them . 3 records are diaplyed on a single page.
when I move to the next page I actually passes through the controller.
there I want to access previous pages value.

how to do it.

the controller is

def viewsearchitems
@srchparams = params[:txt_srch].to_s
@cnt = 1
page = (params[:page] ||= 1).to_i
tems_per_page = 3
offset = (page - 1) * items_per_page
@prods=RealEstate.find_by_sql(“select * from real_estates order
by id”)
@prod_pages = Paginator.new(self, @prods.length, items_per_page,
page)
@items = @prods[offset…(offset + items_per_page - 1)]
end

viewsearchitem.rhtml is

<% if @items != nil %>
<% for result in @items %>






<%= link_to result.id , :action => ‘dispitem’, :id => result %>

<%= result.address %> <%= result.bedroom %> <%= result.area %> <%= result.price %> <% end %> <% if @prod_pages.page_count > 1 %> <%= pagination_links @prod_pages %> <% end %> <% end %>

if I have checkbox associate with each item in every page How do I get
the status of the checkbox in each page when I move from one page to
another

Hello, you can try this:
pagination_links(@prod_pages, { :params => @params})

Also, @items = @prods[offset…(offset + items_per_page - 1)] equal
with
@items = @prods[offset…(offset + items_per_page)]
:slight_smile:

On 9 æÅ×., 08:34, Trupti B. [email protected]