I want to do pagination in my project.For that i installed
gem install mislav-will_paginate --source .
then i wrote require ‘will_paginate’ in my enviornment.rb file.
anything else required?
Then am i able to use it for my application?
how can i call it from my controller.I tried to call paginate…but
error is showing that undefined method paginate…
can anybody help me?

then i wrote require ‘will_paginate’ in my enviornment.rb file.
anything else required?

that’s all to it. if you can start script/server and get no errors for
it, it should be ok so far.

to actually paginate something do this (example for model named

@products = Product.paginate(:all, :order => “products.created_at
:page =>
params[:page].to_i, :per_page => params[:per_page].to_i)

mind, that params[:page] & params[:per_page] should be initialized
per_page should be 1 for first call and set to other pages for further
calls. but will_paginate will
handle most of it.

in the view you get the pagination links like that:
<% unless @products.nil? or @products.empty?%>
<%= will_paginate @products, :inner_window => 2 %>
<% else %>
found nothing
<% end %>

I got error like this…
undefined method `paginate’ for #Class:0x466c408

RAILS_ROOT: C:/InstantRails-2.0-win(3)/rails_apps/invictold
Application Trace | Framework Trace | Full Trace

method_missing' app/models/customer.rb:8:insearch’
app/controllers/customers_controller.rb:6:in `index’

can anybody help me…

Classic pagination has been moved into a plugin since 2.0.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs