I searched in Internet (http://wiki.github.com/mislav/will_paginate/ simple-search and http://railscasts.com/episodes/51), 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 %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Whether FIELD1, FIELD2,FIELD3 are table column heading or values? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
FIELD1, FIELD2 and FIELD3 are table columns and values. They have the same names. On Mar 12, 10:53 am, Priya Buvan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Whether FIELD1, FIELD2,FIELD3 are table column heading or values? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 12, 2009, at 4:54 AM, engamocap wrote:> I searched in Internet (http://wiki.github.com/mislav/will_paginate/ > simple-search and http://railscasts.com/episodes/51), 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 %><%= will_paginate @items, :params => params %> or a suitable subset of the items from params :params => params.reject {|k,v| k !~ /FIELD/ } -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---