ActiveRecord on Rails 2.3.15

59 views
asked Sep 30, 2013 in Database by Nadia32 (540 points)
Hey all
I am using Rains 2.3.15 and what I am trying to do is joining two tables and then selecting columns from both those joined tables. Something like this in SQL:
 select A.id, A.title, B.img_url, B.url from products inner join prices B on A.id = B.product_id where A.is_ showcase = 1
 How can I do the same SQL in ActiveRecords? Can anyone please help me out?
Thanks

1 Answer

0 like 0 dislike
answered Sep 30, 2013 by TopNet (10,360 points)
Try this Products.find(:includes => :prices, :conditions => {: showcase => 1})
...