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
Post a Comment