# \[HELP\] pagination w habtm association and authorization plugin

**URL:** <https://www.ruby-forum.com/t/help-pagination-w-habtm-association-and-authorization-plugin/169203>\
**Category:** Rails\
**Created:** [May 31, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/help-pagination-w-habtm-association-and-authorization-plugin/169203 "2009-05-31T18:47:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [May 31, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/help-pagination-w-habtm-association-and-authorization-plugin/169203/1 "2009-05-31T18:47:39Z")

</div>

I am using the proven authorization plugin to defines roles for users,  
so I can get all groups where a user is ‘member’

@groups = current\_user.group\_memberships

I have an habtm association between groups and events

class Group \< ActiveRecord::Base  
has\_and\_belongs\_to\_many :events  
…  
class Event \< ActiveRecord::Base  
has\_and\_belongs\_to\_many :groups

I am trying to list and paginate (with the will\_paginate plugin) all  
events in all groups a user belongs to…

I thought initially to build an array of ids from @groups and  
paginate :  
@events = Event.paginate :page =\> params[:page], :conditions =\>  
[“group\_id IN(?)”, group\_ids]

but group\_id is not a key in the events table…

any hint ? thanks
