[Rails] newbie question - How can I run the following Query in ActiveRecord ?

2011-11-11 Thread Mahmoud Abdel-Fattah
I'm totally rails newbie, and just started it a couple of days ago moving from PHP, so I've the following query, and want to know how can I do it using ActiveRecord SELECT `sites`.*, `snapshots`.*, `technologies`.* FROM `sites`, `snapshots`, `technologies` WHERE `sites`.id = '1' AND

Re: [Rails] newbie question - How can I run the following Query in ActiveRecord ?

2011-11-11 Thread Colin Law
On 11 November 2011 12:02, Mahmoud Abdel-Fattah mahm...@abdel-fattah.net wrote: I'm totally rails newbie, and just started it a couple of days ago moving from PHP, so I've the following query, and want to know how can I do it using ActiveRecord SELECT `sites`.*, `snapshots`.*,

Re: [Rails] newbie question - How can I run the following Query in ActiveRecord ?

2011-11-11 Thread Mahmoud Said
I think what you are trying to do is joins if your associations are set correctly, then something like below should work Site.joins(:snapshots).joins(:technologies).where(sites.id=1) *Note: *in the where clause, you cannot use :id=1 because :id with the joined tables will be ambigious... you