Hi googling didn't help way too much. I have this website: http://mishareyzlin.com and the time has come for me to implement pagination. Are there any pointers to that direction? Thanks!
Hi, Misha, You should be able to use will_paginate to paginate an ordinary Ruby array. https://github.com/mislav/will_paginate Here's the basic steps: add the gem to your Gemfile gem 'will_paginate', '~> 3.0' Then in your app.rb: require 'will_paginate/array' Then you can do something like: @posts.paginate(:page => params[:page], :per_page => 10) Then in your view, you can show the pagination links with: = will_paginate @posts Hope that helps, --- Wynn Netherland web: http://wynn.fm twitter / skype / facebook: pengwynn linkedin: http://linkedin.com/in/netherland On Sunday, December 11, 2011 at 5:07 PM, Misha Reyzlin wrote: > Hi > googling didn't help way too much. > > I have this website: http://mishareyzlin.com and the time has come for me to implement pagination. Are there any pointers to that direction? > > Thanks!
Hey Wynn, thanks for your reply. I have added this to my `config.ru` file: # pagination require 'will_paginate' require 'will_paginate/array' And in `summaries.haml`, where `pages` is the list of all relevant pages returned with `pages = Page.find_all` I put this: - unless pages.empty? - pages.paginate(:page => params[:page], :per_page => 2) - pages.each do |page| / show each page's sumarry … = will_paginate pages And I get then an error saying "NoMethodError at /notes undefined method `will_paginate' for #<Nesta::App:0x102153850>". Also If I only leave pages.paginate(:page => params[:page], :per_page => 2) in and pass a get param, such as "?page=3", and then do puts pages.length it never changes the length, that is it's not 2, but always the length of all pages. Thanks for your help! Misha Reyzlin On Mon, Dec 12, 2011 at 5:02 AM, Wynn Netherland <wynn.netherland@gmail.com>wrote: > Hi, Misha, > > You should be able to use will_paginate to paginate an ordinary Ruby array. > > https://github.com/mislav/will_paginate > > Here's the basic steps: > > add the gem to your Gemfile > > gem 'will_paginate', '~> 3.0' > > Then in your app.rb: > > require 'will_paginate/array' > > > Then you can do something like: > > @posts.paginate(:page => params[:page], :per_page => 10) > > Then in your view, you can show the pagination links with: > > = will_paginate @posts > > Hope that helps, > > --- > Wynn Netherland > web: http://wynn.fm > twitter / skype / facebook: pengwynn > linkedin: http://linkedin.com/in/netherland > > On Sunday, December 11, 2011 at 5:07 PM, Misha Reyzlin wrote: > > Hi > googling didn't help way too much. > > I have this website: http://mishareyzlin.com and the time has come for me > to implement pagination. Are there any pointers to that direction? > > Thanks! > > >
Try moving the require to your app.rb instead? Pecked on my mobile keyboard, -- Wynn On Dec 18, 2011, at 6:14 AM, Misha Reyzlin <mrejzlin@gmail.com> wrote: Hey Wynn, thanks for your reply. I have added this to my `config.ru` file: # pagination require 'will_paginate' require 'will_paginate/array' And in `summaries.haml`, where `pages` is the list of all relevant pages returned with `pages = Page.find_all` I put this: - unless pages.empty? - pages.paginate(:page => params[:page], :per_page => 2) - pages.each do |page| / show each page's sumarry … = will_paginate pages And I get then an error saying "NoMethodError at /notes undefined method `will_paginate' for #<Nesta::App:0x102153850>". Also If I only leave pages.paginate(:page => params[:page], :per_page => 2) in and pass a get param, such as "?page=3", and then do puts pages.length it never changes the length, that is it's not 2, but always the length of all pages. Thanks for your help! Misha Reyzlin On Mon, Dec 12, 2011 at 5:02 AM, Wynn Netherland <wynn.netherland@gmail.com>wrote: > Hi, Misha, > > You should be able to use will_paginate to paginate an ordinary Ruby array. > > https://github.com/mislav/will_paginate > > Here's the basic steps: > > add the gem to your Gemfile > > gem 'will_paginate', '~> 3.0' > > Then in your app.rb: > > require 'will_paginate/array' > > > Then you can do something like: > > @posts.paginate(:page => params[:page], :per_page => 10) > > Then in your view, you can show the pagination links with: > > = will_paginate @posts > > Hope that helps, > > --- > Wynn Netherland > web: http://wynn.fm > twitter / skype / facebook: pengwynn > linkedin: http://linkedin.com/in/netherland > > On Sunday, December 11, 2011 at 5:07 PM, Misha Reyzlin wrote: > > Hi > googling didn't help way too much. > > I have this website: http://mishareyzlin.com and the time has come for me > to implement pagination. Are there any pointers to that direction? > > Thanks! > > >