ruby on rails - How to do pagination with cancan? -


i'm looking pagination cancan it's not obvious how integrate gems such will_paginate.

ideally cancan's load_resource delegate will_paginate , add conditions. example in cancan i've declared guest users

can :read, post, :published => true 

and handled automatically load_resource. i'd have will_paginate page through these results.

any ideas.

regards

brad

this simple kaminari https://github.com/amatsuda/kaminari

in postscontroller do

  before_filter :load_by_pagination, :only => :index   def load_by_pagination     @posts = post.accessible_by(current_ability).order("published_date desc").page params[:page]   end  

note kaminari works new rails3 activerelation framework it's possible chain methods build scope. , cancan activerelation friendly both chain together.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -