Pagination problem

Hi,
please help…

In controller…

def index
@customers = Customer.find(:all)
pagination code here…
end

In index.html.erb

Displayes list of customers and has pagination 1,2,3,4…etc.

On clicking page 2, it will again run this(Customer.find(:all)) query in
controller. So, there will be lack of performance.

So, how to increase the mysql performace? Can i use the index as below
or any other way is there?

ALTER TABLE customers ADD INDEX(customer_id);

you have download wii_paginate and put vendor/plugin then

change environment.rb
put after end require ‘will_paginate’
then in ur controller #@images = Image.paginate :page => params[:page],
:per_page => 2 do some thing like this

and in ur index page <%= will_paginate @images%>

this is ur paging

Wap A. wrote:

you have download wii_paginate and put vendor/plugin then

change environment.rb
put after end require ‘will_paginate’
then in ur controller #@images = Image.paginate :page => params[:page],
:per_page => 2 do some thing like this

and in ur index page <%= will_paginate @images%>

this is ur paging

Hi Wap A.,

I am not using any plugins for pagination. I have written my own code
for the pagination.

So, how to increase the mysql performace? Can i use the index as below
or any other way is there?
ALTER TABLE customers ADD INDEX(customer_id);

if you have written your own pagination then start using :limit option
in find. I guess you can also use :start

On Aug 18, 3:48 am, Venkat E. [email protected]
wrote:

this is ur paging
Posted viahttp://www.ruby-forum.com/.
Is there an actual reason you’re rolling your own code when
will_paginate handles this prettttty well already?

And of course you need the right indexes in place, but Customer.find
(:all) kindof defeats the whole purpose of pagination. A non worst-
possible solution for pagination involves using LIMIT and OFFSET in
your query. But I’m really curious as to why you’re insistent on re-
inventing the wheel (honestly, fairly poorly) here.