Jeff Pritchard | 9 Jul 03:01

joins with paginate syntax problem


First, let me just say "YES, I KNOW, I SHOULD BE USING WILL PAGINGATE
INSTEAD".

Now, with that out of the way, and assuming that I have some reason
(stubornness, laziness, whatever) to keep using paginate on this old
project in 1.2 rails...

I'm trying to set up my conditions with a "joins" parameter.  I have a
join table which follows the active record expectation for a habtm
association, which is unfortunately inconsistent pluralization wise with
a regular table name.  the join table is called "events_owners", so it
is plural and that seems to screw things up with the conditions.

Here's my code right now...
    @events_for_reports_pages, @events_for_reports = paginate :events,
          :joins => :events_owners,
          :conditions => [ "events_owners.owner_id=?" , @owner.id ],
          :order => :created_at,
          :per_page => 50

Here's the error I get back:
Mysql::Error: Unknown column 'events_ownerss.owner_id' in 'where
clause': SELECT count(*) AS count_all FROM events  events_owners WHERE
(events_ownerss.owner_id=1)

Any ideas?  I think it is because the events_owners table is pluralized,
where as a normal table isn't, but maybe it is something else.

thanks,
jp
--

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane