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); -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.
Wap Addon 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 pagingHi Wap Addon, 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); -- Posted via http://www.ruby-forum.com/.
On Aug 18, 3:48 am, Venkat Eee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Wap Addon 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 Addon, > > 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); > -- > 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.