Get and Set method in Ruby on Rails

Hi,

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?

On Mon, Oct 5, 2009 at 12:42 AM, venki [email protected] wrote:

Hi,

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?

Ruby has attr_* for getters and setters:

http://www.ruby-doc.org/core/classes/Module.html#M001678


Greg D.
http://destiney.com/

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