Skip to content

Instantly share code, notes, and snippets.

@delagoya
Created August 10, 2010 14:53
Show Gist options
  • Save delagoya/517391 to your computer and use it in GitHub Desktop.
Save delagoya/517391 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sequel'
require 'sequel/extensions/pagination'
DB.create_table :projects do
primary_key :id
String :name
String :description, :text => true
DateTime :created_at
DateTime :updated_at
end
class Project < Sequel::Model
plugin :timestamps # auto set created_at & updated_at
end
projects = Project
recent_projects = Project.filter(:updated_at > (Time.now - 10.days))
first_page = recent_projects.paginate(1, 20)
second_page = recent_projects.paginate(2, 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment