You can use JQuery and Ajax to handle the pagination feature. However, there is a much easy way to have this feature working if you use Ruby on Rails. Here is how you got it work: 

  • First install the Ruby plugin called  in Rails system will_paginate by the following command: 

gem install will_paginate

  • Then update your gem file with this line: 

gem ‘will_paginate’ , ‘>= 3.0.pre’

  • Run “bundle install” and restart the rails server to update the settings.
  • In your view file (for example : /app/views/photos/index.html.erb) embedding the plugin code inside <body></body>, then reload your page in browser.

 <%= will_paginate @photos %>