Skip to content

Instantly share code, notes, and snippets.

@thbar
Created December 26, 2008 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thbar/40159 to your computer and use it in GitHub Desktop.
Save thbar/40159 to your computer and use it in GitHub Desktop.
require 'active_record'
require 'action_view'
require 'will_paginate'
WillPaginate.enable
def items(page)
@current_page = page.to_i
@items = Item.paginate :page => @current_page, :order => 'id DESC', :per_page => 10
end
#{will_paginate @items, :param_name => :items, :class => 'pagination' }
module Ramaze
module Helper
module WillPaginateForRamaze
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TagHelper
include WillPaginate::ViewHelpers
def url_for(args)
url = case args
when Hash;
resource = args.keys.first
page_number = args[resource]
hash_url = "/#{resource}"
hash_url << "/#{page_number}" unless page_number == 1
hash_url
when String;
args
end
end
def params
request.params
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment