I am new to Rails. I have three tables a, b, c
b has 2 columns:
b1 and b2
c has 2 columns: c1 and c2
a has 3 columns: a1, b1 (foreign key) and c1 (foreign key)
I want to get the distinct (b2, c2) pairs by giving a value for a1
I tried something like
a.find(:all, :joins => [:b, :c], :select => "b2, c2", :conditions => {:a => {:a1 => Time.now.midnight. ... Time.now}}, :group => "b2, c2")
The SQL that this produces works fine and I am able to see the results. But I think since I am doing a a.find, I am not able to retrieve b2, c2 from the result set.
How can I modify this so that I can get b2 and c2?