Sinatra 用 Sinatra 开发的应用如何使用 will_paginate 翻页?

freemem · 2012年04月30日 · 最后由 yakjuly 回复于 2012年05月02日 · 3875 次阅读

no rails.

搜索谷歌。

Sequel的话

class Post < Sequel::Model
  Sequel.extension :pagination

  # here is your code
  ...
end

使用的时候就可以

Post.paginate(1, Post.page_size)

@ywjno 会提示没有 pagination 这个方法。

#3 楼 @freemem 我少些了个 where 条件。。。 Post.filter(...).paginate(1, Post.page_size)...这个地方请替换成自己需要的 Sequel的文档其实还是不错的,虽然有些东西隐藏得比较深

@ywjno 谢谢,有空我再看看。

gem "will_paginate", '~> 3.0'
require "sinatra"
require "sinatra/activerecord"
require "will_paginate"
require 'will_paginate/finders/active_record'


需要 登录 后方可回复, 如果你还没有账号请 注册新账号