SlideShare a Scribd company logo
1 of 14
Download to read offline
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_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)
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,...
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
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)
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 %>
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 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)
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
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'
Questions & Answers
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
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

More Related Content

What's hot

JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsSpike Brehm
 
a_rubygem_for_iknow_api
a_rubygem_for_iknow_apia_rubygem_for_iknow_api
a_rubygem_for_iknow_apiNov Matake
 
RVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerRVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerKeith Pitty
 
Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014Andrey Listochkin
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
Introducing Merb
Introducing MerbIntroducing Merb
Introducing MerbBalint Erdi
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptSpike Brehm
 
Ruby Sapporo Night Vol2
Ruby Sapporo Night Vol2Ruby Sapporo Night Vol2
Ruby Sapporo Night Vol2Koji SHIMADA
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemLucas Renan
 
An Introduction to node.js
An Introduction to node.jsAn Introduction to node.js
An Introduction to node.jsnodejsbcn
 
Cuvic OnDemand on JRuby
Cuvic OnDemand on JRubyCuvic OnDemand on JRuby
Cuvic OnDemand on JRubyKoichiro Ohba
 
MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10Jiri Danihelka
 
Inesita — Ihor Strumetskyi
Inesita — Ihor StrumetskyiInesita — Ihor Strumetskyi
Inesita — Ihor StrumetskyiRuby Meditation
 
A Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on RailsA Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on RailsRafael García
 

What's hot (19)

JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
 
Very Xd
Very XdVery Xd
Very Xd
 
RubyGem
RubyGemRubyGem
RubyGem
 
a_rubygem_for_iknow_api
a_rubygem_for_iknow_apia_rubygem_for_iknow_api
a_rubygem_for_iknow_api
 
TsWorkflow
TsWorkflowTsWorkflow
TsWorkflow
 
RVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerRVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby Tracker
 
Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Introducing Merb
Introducing MerbIntroducing Merb
Introducing Merb
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
Ruby Sapporo Night Vol2
Ruby Sapporo Night Vol2Ruby Sapporo Night Vol2
Ruby Sapporo Night Vol2
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - Ecosystem
 
Juju presentation
Juju presentationJuju presentation
Juju presentation
 
An Introduction to node.js
An Introduction to node.jsAn Introduction to node.js
An Introduction to node.js
 
Cuvic OnDemand on JRuby
Cuvic OnDemand on JRubyCuvic OnDemand on JRuby
Cuvic OnDemand on JRuby
 
MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10MVVM Windows UWP apps with Template 10
MVVM Windows UWP apps with Template 10
 
Inesita — Ihor Strumetskyi
Inesita — Ihor StrumetskyiInesita — Ihor Strumetskyi
Inesita — Ihor Strumetskyi
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
A Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on RailsA Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on Rails
 

Similar to Will paginate and kaminari

RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)scandiweb
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular applicationmirrec
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudHiro Asari
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyDeepak Chandella
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyFabio Akita
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
 
Introduction to padrino
Introduction to padrinoIntroduction to padrino
Introduction to padrinoVictor Stan
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done RightMariusz Nowak
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsTom Z Zeng
 
Radiant CMS - Boston.rb 7/12
Radiant CMS - Boston.rb 7/12Radiant CMS - Boston.rb 7/12
Radiant CMS - Boston.rb 7/12joliveira
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & CucumberUdaya Kiran
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails FinalRobert Postill
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails BasicsAmit Solanki
 
Wordpress Workflow
Wordpress Workflow Wordpress Workflow
Wordpress Workflow Filippo Dino
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFabio Akita
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineNascenia IT
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 

Similar to Will paginate and kaminari (20)

RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using ruby
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
 
Sinatra
SinatraSinatra
Sinatra
 
Introduction to padrino
Introduction to padrinoIntroduction to padrino
Introduction to padrino
 
JavaScript Modules Done Right
JavaScript Modules Done RightJavaScript Modules Done Right
JavaScript Modules Done Right
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
 
Radiant CMS - Boston.rb 7/12
Radiant CMS - Boston.rb 7/12Radiant CMS - Boston.rb 7/12
Radiant CMS - Boston.rb 7/12
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Wordpress Workflow
Wordpress Workflow Wordpress Workflow
Wordpress Workflow
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding Guideline
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Will paginate and kaminari

  • 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'
  • 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