will_paginate
https://github.com/mislav/will_paginate
Ruby
Pagination library for Rails and other Ruby applications
WillPaginate::ActiveRecord::BaseMethods#paginate_by_sql
Wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string
based on the params otherwise used by paginating finds: +page+ and
+per_page+.
Example:
@developers = Developer.paginate_by_sql ['select * from developers where salary > ?', 80000],
:page => params[:page], :per_page => 3
A query for counting rows will automatically be generated if you don't
supply <tt>:total_entries</tt>. If you experience problems with this
generated SQL, you might want to perform the count manually in your
application.Edit
git clone [email protected]:mislav/will_paginate.git
cd will_paginate
open lib/will_paginate/active_record.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-WillPaginate--ActiveRecord--BaseMethods-paginate_by_sql-for-pr
# Commit to gitgit add lib/will_paginate/active_record.rbgit commit -m "better docs for WillPaginate::ActiveRecord::BaseMethods#paginate_by_sql"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-WillPaginate--ActiveRecord--BaseMethods-paginate_by_sql-for-pr
hub pull-request
# Celebrate!