Hi all, i used pagination and it is working fine. But i''ve the folloeing problem.... * For ex: if i''ve 10 pages and each page contains 10 posts.if i delete a post in the 4th page then that post is deleted and the 1st page is displayed but i want to display 4th page i,e.; the page where i deleted the post should be displayed. so how to get this... -- 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 -~----------~----~----~----~------~----~------~--~---
it would be helpful to know, how exactly you''re using pagination, since there are different ways to do this... if you use will_paginate plugin you would have a line like this @products = Product.paginate(:all, :order => "views DESC", :page => params[:page], :per_page => params[:per_page]) there you would simply set :page => to whatever you want. if you find with :limit, you can set :offset to the pagenumber you want to display -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> it would be helpful to know, how exactly you''re using pagination, since > there are different ways to do this... > > if you use will_paginate plugin you would have a line like this > > @products = Product.paginate(:all, :order => "views DESC", :page => > params[:page], :per_page => params[:per_page]) > > there you would simply set :page => to whatever you want. > > if you find with :limit, you can set :offset to the pagenumber you want > to displaySorry i didn''t mention completely.... well i''m using a complex query which consists of some 4-5 tables .... -- 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 -~----------~----~----~----~------~----~------~--~---
> > Sorry i didn''t mention completely.... > well i''m using a complex query which consists of some 4-5 tables ....so how would that complex query lokk like? you''re using plain SQL? then you can give SQL a second param with the LIMIT argument like: LIMIT 3, 3 where the second arg is the pagenumber (like offset in the above examples) or you use find with :include, then the :limit, :offset should still work. otherwise please post your code... -- 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 -~----------~----~----~----~------~----~------~--~---
For deletion this is rather straightforward: you just remember the page number and jump back to it (with a check to make sure that page still exists after you deleted one) But if I understand correctly, you want the more general case that after an update it should jump to the page where the new/updated record is displayed (and perhaps do a yellow flash thing there). I had the same problem. Neither the classic, nor will_paginate can do this for you automatically and there is no SQL statement to find the place of a record in a table. But if your table is sorted on a unique key you can get the new page number by doing a properly constructed "count smaller than key" and dividing that by the page length. If it''s not sorted on a unique key you have to brute force it: read in the whole table (use select on key) to find the place in the list. On May 8, 9:04 am, Vamsi Krishna <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > i used pagination and it is working fine. But i''ve the folloeing > problem.... > > * For ex: if i''ve 10 pages and each page contains 10 posts.if i delete > a post in the 4th page then that post is deleted and the 1st page is > displayed but i want to display 4th page i,e.; the page where i deleted > the post should be displayed. > so how to get this... > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---