关于will_paginate的用法,网上有很多介绍,这里不再详细说明。
will_paginate用在查询时,一定要注意在fom_tag标签里注明:method=>"get",不然,会出现查询结果从第二页开始发生错误。
因为查询的参数会在点击第二页时丢失。
 
Parameters: {"type"=>"student_no", "action"=>"search", "controller"=>"students", "query"=>"2"}
    Student Load (0.000000)     SELECT * FROM students WHERE (student_no like '%2%') ORDER BY student_no LIMIT 0, 1
 
Parameters: {"action"=>"search", "controller"=>"students", "page"=>"2"}
    Student Load (0.000000)     SELECT * FROM students WHERE (student_no like '%%') ORDER BY student_no LIMIT 1, 1
 
而加上:method=>"get"之后,
Parameters: {"type"=>"student_no", "action"=>"search", "controller"=>"students", "page"=>"1", "query"=>"2"}
    Student Load (0.000000)     SELECT * FROM students WHERE (student_no like '%2%') ORDER BY student_no LIMIT 0, 1
 
    Parameters: {"type"=>"student_no", "action"=>"search", "controller"=>"students", "page"=>"2", "query"=>"2"}
    Student Load (0.000000)     SELECT * FROM students WHERE (student_no like '%2%') ORDER BY student_no LIMIT 1, 1
如果用restful路由的话,要在routes中这么声明: 
map.resources :students,:collection=>{:search=>:get}