How do I convert this active record query to a rails 3 query

Christian Fazzini wrote:

The following SQL:

select * from medias m
left join artists a on = m.artist_id
left join users u on = a.user_id
left join genres g on = u.genre_id
where = 'Acoustic'

is the equivalent to (which works):

Video.find(:all, :conditions => [' = ?',
'Acoustic'], :include => {:artist => {:user => :genre}})

However, I know that the rails 3 active record query uses the .where()
clause. How can I convert the above to something like:

Song.where({:genre => 'Acoustic', :include => {:artist => {:user
=> :genre}}}) <==== Does NOT work

Song.where({ :genre => 'Acoustic' }).includes({ :artist => { :user =>
:genre }})

I think that's going to try to "WHERE medias.genre = 'Acoustic'"

   .where([' = ?', 'Acoustic'])

(guessing that both Song and Video are STI subclasses of Media or else you've omitted some structure that might affect the answer(s) that you'll receive)


Rob Biedenharn

Yea, thanks for the feedback. I ended up with
Video.where([' = ?', 'Acoustic']).includes({:artist =>
{:user => :genre}}) which seems to work