诗歌rails之 will_paginate
安装will_paginate
svn:
svn://errtheblog.com/svn/plugins/will_paginate
git:
script/plugin install git://github.com/mislav/will_paginate.git
在Model中使用will_paginate
- # models/product.rb
- def self.search(search, page)
- paginate :per_page => 5, :page => page,
- :conditions => ['name like ?', "%#{search}%"],
- : order => 'name'
- end
- # products_controller.rb
- def index
- @products = Product.search(params[:search], params[:page])
- end
- <!-- products/index.rhtml -->
- <%= will_paginate @products %>
莫愁前路无知己,天下无人不识君。