paginated record numbers

# application_helper.rb
# record numbering inside paginated admin index views
def paginated_record_number(offset)
  # TODO find out will_paginate page_count query
  page = params[:page] ? params[:page].to_i : nil
  (page ? page - 1 : 0) * ( params[:per_page] || 30) + offset + 1
end

# use in views like so
<%= paginated_record_number(idx) %>


Leave a Reply

Formatting: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>