1 2 |
# firefox (in dev so slow): http://bookerbee.com/bookables?page=7&&sleeps=2&when=31&where=1r |
shared/_paginate.html.haml
1 2 3 4 5 6 7 8 9 |
%ul %li.prev =paginate_nav(:prev) -@count[:pages].times do |i| %li =paginate_nav(i+1) %li.next =paginate_nav(:next) |
ApplicationHelper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
render :partial => 'shared/paginate' end current_page = params[:page].to_i case page when :next position = current_page + 1 when :prev position = current_page - 1 else position = page end Hash[*request.query_parameters.map {|it| it.include?("page") ? it = ["page", position] : it}.flatten] end link = link_to(kind.to_s.titlecase, bookables_path(paginate_params(kind))) current_page = params[:page].to_i page = kind.to_s.to_i if page > 0 && page != current_page link elsif kind == :prev && current_page > 1 link elsif kind == :next && current_page < @count[:pages] link else "<span></span>" end end end |
CONTROLLER
1 2 3 4 5 6 7 |
|
MODEL
1 2 3 4 5 6 |
basically add query << " ORDER BY id LIMIT 150 OFFSET " unless count (using the same query for count and select): |
index view
1 2 3 4 5 6 7 8 9 10 11 12 |
#refine =render :partial => "form" #results .header %p.counts==We found <em>#{@count[:all]}</em> properties from #{pluralize(@brands.size,'hospitality brand')} .pagination =pagination %ul =render :partial => @bookables .clear =javascript_include_tag 'search' |

