Rails Gems:
Will_Paginate
Kaminari
Kuyseng Chhoeurn
Contents
● Gem vs RubyGems
● RVM, Gemset, bundler, rvmrc
● Will_Paginate
● Kaminari
● Q/A ?
● Practice
● References
RubyGems vs Gem
● Gem is a libraries (a collection of code to do
something)
e.g. rails, rspec, rake, bundler, will_paginat...
RVM, Bundler
● RVM (Ruby Version Manager) is a command-
line tool which allows you to easily install,
manage, and work wit...
Gemset, rvmrc
● Gemset is a set of gems.
e.g. rvm gemset list, rvm gemset create rails4
● rvmrc is a dot file in repo to a...
will_paginate
● Introduction:
will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Merb,
Dat...
will_paginate
3) render page links in the view
4) see the result in browser
5) make those pagination links prettier
# Down...
will_paginate
7) See the result
● Git Commit:
$ git status
$ git add --all
$ git commit -m 'added will_paginate'
kaminari
●
Introduction:
A Scope & Engine based, clean, powerful, customizable
and sophisticated paginator for modern web ...
kaminari
3) render page links in the view
<%= paginate @movies %>
4) see the result in browser
5) play around with theme
$...
kaminari
6) play around with helper & locales
- delete first, last and keep previous & next
- use outer_windows: 3
- use l...
Questions & Answers
Practice
● Add header paginate have Previous and Next buttons
● Add footer paginate with outer_window: 3 in bootstrap
them...
References:
● http://en.wikipedia.org/wiki/RubyGems
● http://bundler.io/
● https://github.com/bundler/bundler
● https://rv...
Upcoming SlideShare
Loading in …5
×

Will paginate and kaminari

2,816 views

Published on

it's used for my presentation about paginate in rails

Published in: Technology
  • Be the first to comment

Will paginate and kaminari

  1. 1. Rails Gems: Will_Paginate Kaminari Kuyseng Chhoeurn
  2. 2. Contents ● Gem vs RubyGems ● RVM, Gemset, bundler, rvmrc ● Will_Paginate ● Kaminari ● Q/A ? ● Practice ● References
  3. 3. RubyGems vs Gem ● Gem is a libraries (a collection of code to do something) e.g. rails, rspec, rake, bundler, will_paginate, kaminari,... ● RubyGems is a tool designed to easily manage the installation of gems, and a server for distributing them. e.g. gem list, gem install, gem uninstall, gem –help command (#list all gem commands)
  4. 4. RVM, Bundler ● RVM (Ruby Version Manager) is a command- line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. e.g. rvm list, rvm install, rvm use, rvm gemset create,... ● Bundler is a gem to manage your application's gem dependencies with less pain. (after install ruby) e.g. bundle install, bundle update,...
  5. 5. Gemset, rvmrc ● Gemset is a set of gems. e.g. rvm gemset list, rvm gemset create rails4 ● rvmrc is a dot file in repo to auto choose gemset ... e.g. rvm gemset create rails4, rvm gemset use rails4, rvm gemset use rails4, rvm gemset create rails4
  6. 6. will_paginate ● Introduction: will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Merb, DataMapper and Sequel. ● Set up Git: $ git init $ git add --all $ git commit -m 'before will_paginate' ● How to Use: 1) Add in Gemfile & bundle install gem 'will_paginate', '~> 3.0' 2) perform a paginated query Movie.released.paginate(page: params[:page], per_page: 3)
  7. 7. will_paginate 3) render page links in the view 4) see the result in browser 5) make those pagination links prettier # Download css or sass from “http://mislav.uniqpath.com/will_paginate/” into “app/assets/stylesheets/” # add in applications.css *= require pagination 6) Use css class in the paginate helper <%= will_paginate @movies, class: 'flickr_pagination' %> <%= will_paginate @movies %>
  8. 8. will_paginate 7) See the result ● Git Commit: $ git status $ git add --all $ git commit -m 'added will_paginate'
  9. 9. kaminari ● Introduction: A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for modern web app frameworks and ORMs. ● How to Use: 1)Add in Gemfile & bundle install gem 'kaminari' 2) perform a paginated query Movie.released.page(params[:page]).per(3)
  10. 10. kaminari 3) render page links in the view <%= paginate @movies %> 4) see the result in browser 5) play around with theme $ rails g kaminari:views # to list themes $ rails g kaminari:views google $ rails d kaminari:views google # destroy theme $ rails g kaminari:views bootstrap
  11. 11. kaminari 6) play around with helper & locales - delete first, last and keep previous & next - use outer_windows: 3 - use link_to_next_page, link_to_previous_page Git commit $ git status $ git add --all $ git commit -m 'kaminari with some custome'
  12. 12. Questions & Answers
  13. 13. Practice ● Add header paginate have Previous and Next buttons ● Add footer paginate with outer_window: 3 in bootstrap theme and no first and last link
  14. 14. References: ● http://en.wikipedia.org/wiki/RubyGems ● http://bundler.io/ ● https://github.com/bundler/bundler ● https://rvm.io ● http://www.codeschool.com/courses/try-git ● http://rubygems.org/ ● https://github.com/mislav/will_paginate ● https://github.com/amatsuda/kaminari ● http://railscasts.com/episodes/51-will-paginate-revised ● http://railscasts.com/episodes/254-pagination-with-kaminari

×