Http://localhost:3000/products/page/:page/pre_page/:pre_page format to use pagination implementation
: page is the first few pages
: pre_page each page are the number of records
In config / routes.rb add
map.connect 'products / page /: page / pre_page /: pre_page',: controller => 'products',: action =>' page '
In app / controllers / products_controller.rb add method
def page
@ page = params [: page]
@ pre_page = params [: pre_page]
# Deal with the procedures
end
Can now be used to achieve the product http://localhost:3000/products/page/1/pre_page/10 the first page (10 records per page) to visit.
If each pre_page add parameters would be very cumbersome, in config / routes.rb to add one more
map.connect 'products / page /: page',: controller => 'products',: action =>' page '
In the controller to change the @ pre_page deal about, is as follows:
def page
@ page = params [: page]
@ pre_page = params [: pre_page] | | 5
# Deal with the procedures
end
So that we can use the Product http://localhost:3000/products/page/1 to visit the first page (page 5 records).
Reference







