2014-01-23 58 views
0

我使用Temping gem來創建臨時表。加入帶溫度表的AR模型

我需要加入我用AR模型創建的臨時表。任何想法如何實現?

這裏是原始SQL查詢:

SELECT * FROM `example1` as t1 JOIN `example2` as t2 on t1.`book_name` = t2.`book_name` and t1.`author` = t2.`author` and t1.`date`= t2.`date` 

在這種情況下,例1是臨時表(經由臨時工寶石創建),和實施例2是實際的AR模型。

回答

0

由於臨時工創建AR對象,我想你可以使用類似:

Example1.joins("example2 ON example1.book_name = example2.book_name ... etc").find_all