I working on Ruby on Rails.I using Ajax in that.While using pagination
in my application first time only I want to give request to Mysql Data
Base ,If user click second page it should not take from database. Here
I can use Set and get methods or different method will be there. How
to implement this?
I working on Ruby on Rails.I using Ajax in that.While using pagination
in my application first time only I want to give request to Mysql Data
Base ,If user click second page it should not take from database. Here
I can use Set and get methods or different method will be there. How
to implement this?
Well, you’re not going to be doing this in Ruby, since HTTP is
stateless. Since you’re using AJAX, you might as well store your
entire resultset as JS, and fetch each page from your local
collection. That said, maybe you should look at Mislav will_paginate
(GitHub - mislav/will_paginate: Pagination library for Rails and other Ruby applications). Sure, you’ll hit the DB for
each page, but it’s simple to implement, it’s well tested and it
performs reasonably well.
Cheers,
Tim
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.