Forum: Ruby on Rails Pagination

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.
(Guest)
on 2007-07-30 17:31
(Received via mailing list)
When using the pagination class, you can specify the :include
parameter.  Is it possible to specify two for a table that references
two relations?  For example a POST has both a USER and an
ORGANIZATION.  Would the correct syntax be:

      @posts_pages, @posts = paginate(:posts,
        :include => :user,
                                :include => :organizations,
        :order => 'published_at DESC',
        :conditions => "organization_id=#{params[:organization_id].to_i}
AND published = true")
Jacob A. (Guest)
on 2007-07-30 17:35
(Received via mailing list)
removed_email_address@domain.invalid wrote:
> AND published = true")
According to the API docs, paginate will pass the include options onto
#find which in turn would expect an array, so:

  :include => [:user, :organisation]

is the way to do it.

--
Cheers,
- Jacob A.
(Guest)
on 2007-07-30 17:43
(Received via mailing list)
Many Thanks
This topic is locked and can not be replied to.