> 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
Product):
@products = Product.paginate(:all, :order => "products.created_at
DESC",
:page =>
params[:page].to_i, :per_page => params[:per_page].to_i)
mind, that params[:page] & params[:per_page] should be initialized
properly
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 %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---