Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14611 reviews 1734 hosting providers

Questions & Answers

ActiveRecord on Rails 2.3.15

Sep 30, 2013 by Nadia32
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?

1 Answer

0 votes
Sep 30, 2013 by TopNet
Try this Products.find(:includes => :prices, :conditions => {: showcase => 1})