I’m having trouble with the has_and_belongs_to_many relationship and
using the paginate function. I’m trying to list all the Requests that
have a particular Tag on them and paginate the results. Here is what I
was doing before I tried to paginate. And BTW it works:
@featureRequests = Request.find( :all,
:conditions => “tags.id = #{@params[‘id’]}”,
:order => @params[‘sortBy’].nil? ? ‘created_on’ :
@params[‘sortBy’],
:include => :tags )
Here is what I tried to do with pagniate function
@featureRequests_pages, @featureRequests = paginate( :request,
:order => @params[‘sortBy’].nil? ? ‘requests.created_on’ :
@params[‘sortBy’],
:per_page => 25,
:include => ‘tags’,
:conditions => “tags.id = #{@params[‘id’]}”)
So my model is Request has_and_belongs_to_many Tags and a Tag
has_and_belongs_to_many Requests. (Don’t know if that is biting me or
not). However, my condition to the paginate function can’t find the
tags table. tags.id is an unknown table. It looks like it’s not joining
my tables together. On a side note if I just list all the Requests it
does work with the paginate function. I jsut can’t get it to honor the
conditions. What am I missing?
Thanks
Charlie