rails 3使用will_paginate分页

ruby 1.9.2
rails 3.1.0
will_paginate 3.0.1

Gemfile里添加
gem 'will_paginate', '3.0.1'


改写controller,
@products = Product.paginate(:per_page => 2, :page => params[:page])


改写index.html.erb
加上
<%= will_paginate @products %>


ok

你可能感兴趣的:(html,Ruby,Rails)