Your SlideShare is downloading. ×
Will paginate and kaminari
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Will paginate and kaminari

1,716
views

Published on

it's used for my presentation about paginate in rails

it's used for my presentation about paginate in rails

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,716
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Rails Gems: Will_Paginate Kaminari Kuyseng Chhoeurn
  • 2. Contents ● Gem vs RubyGems ● RVM, Gemset, bundler, rvmrc ● Will_Paginate ● Kaminari ● Q/A ? ● Practice ● References
  • 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. 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. 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. 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. 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. will_paginate 7) See the result ● Git Commit: $ git status $ git add --all $ git commit -m 'added will_paginate'
  • 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. 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. 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. Questions & Answers
  • 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. 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