Forum: Ruby on Rails Pagination with habtm

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.
Josh (Guest)
on 2006-05-15 19:14
Hello-

I am building a discussion board-like application in which messages are
associated with one or more workgroups via has_and_belongs_to_many.  I
would like to be able to display to my users a distinct list of messages
for the workgroup(s) that they are part of in paginated form.  The SQL
for this query would be something like the following:

select distinct (m.id), m.title, m.created_at from messages m,
messages_workgroups mw, workgroups w where m.id = mw.message_id and w.id
= mw.workgroup_id and w.id in (1,2,3)

How can I do something like this using the pagination functionality?  I
feel as if I might be missing something simple here.

Thanks.
This topic is locked and can not be replied to.