Will_paginate problem

I searched in Internet (http://wiki.github.com/mislav/will_paginate/
simple-search and #51 will_paginate - RailsCasts), but I can’t
solve my problem about pagination. The first page is ok, but when I
click the “Next page” or any other page link, I lose the FIELD1,
FIELD2, FIELD3 parameter(s). Can you help me? Thank you very much.

class Model < ActiveRecord::Base

def self.display(cond, par, page)
paginate :all,
:include => [:table1, :table2],
:conditions => [cond, par].flatten,
:page => page,
:per_page => 10
end

end

class ModelController < ApplicationController

def start

end

def view
condition = “1=1”
param = []
(condition+=" AND models.FIELD1=?“; param << params
[:FIELD1].values) if params[:FIELD1]
(condition+=” AND models.FIELD2=?“; param << params
[:FIELD2].values) if params[:FIELD2]
(condition+=” AND models.FIELD3=?"; param << params
[:FIELD3].values) if params[:FIELD3]
@items = Model.display(condition, param, params[:page])
end

end

view.html.erb


<%= will_paginate @items %>

start.html.erb

<% form_tag(:action => “view”, :method => “get”) do %>
… # define FIELD1, FIELD2 and FIELD3
<% end %>

Whether FIELD1, FIELD2,FIELD3 are table column heading or values?

FIELD1, FIELD2 and FIELD3 are table columns and values. They have the
same names.

On Mar 12, 10:53 am, Priya B. [email protected]

I think you are not getting my question… I asked whether FIELD1,
FIELD2,FIELD3 are table column headings? Like

Eg:

S.No Name RollNo Address
1 xx xxx xxxx

S.No Name RollNo Address are column heading. Need to show this in all
pages?

On Mar 12, 2009, at 4:54 AM, engamocap wrote:

def self.display(cond, par, page)

(condition+=" AND models.FIELD2=?"; param << params

<%= will_paginate @items %>

start.html.erb

<% form_tag(:action => “view”, :method => “get”) do %>
… # define FIELD1, FIELD2 and FIELD3
<% end %>

<%= will_paginate @items, :params => params %>

or a suitable subset of the items from params

:params => params.reject {|k,v| k !~ /FIELD/ }

-Rob

Rob B. http://agileconsultingllc.com
[email protected]