How adh? Rex? polymorphic? over tables in a query? You?

Hi all,

I have 2 polymorphic associations through which I need to query.

I have a news_article table which has a polymorphic association to teams, players, etc. Those teams, players, etc have a polymorphic association to photos through phototenic.

I need to find all articles that have at least one picture that is 500px wide.

The Article model I have a has_many :teams (through the polymorphic table)
and in the teams I have a has_many :photos (though another polymorphic table)

I thought that I could use joins like this

Article.find(:last, :joins => {:teams => :photos}, :conditions => “photos.aspect_ratio < 1.55 AND photos.aspect_ratio > 1.30″)

but it is not working. Any ideas?

This entry was posted in Codes & Scripts and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>