[Rails] How do I convert this active record query to a rails 3 query
The following SQL:
select * from videos v
left join artists a on a.id = v.artist_id
left join users u on u.id = a.user_id
left join genres g on g.id = u.genre_id
where g.name = 'Acoustic'
is the equivalent to (which works):
Video.find(:all, :conditions => ['genres.name = ?',
'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:
Video.where({:genre => 'Acoustic', :include => {:artist => {:user
=> :genre}}}) <==== Does NOT work. What am I missing?
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home