Forum: Ruby on Rails [HELP] pagination w habtm association and authorization plugin...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-05-31 18:47
(Received via mailing list)
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
This topic is locked and can not be replied to.