2012-04-13 59 views
1

上搜索我有以下代碼:執行實例對象

@anatomy = Anatomy.find_by_sql(" some long sql here") 

我想執行的@anatomy結果集的搜索。

我試了下面的代碼,但它似乎並沒有工作。

@anatomy_subset = @anatomy.find :first, :conditions => ["public_id = ?", public_id ] 

它給我:

wrong number of arguments (2 for 1) 

如何搜索@anatomy實例對象上的東西嗎?

非常感謝您的幫助。

回答

1

你不能讓SQL搜索出來的SQL服務器,而是執行此操作:

subset = @anatomy.select { |entity| entity.public_id == public_id } 
+0

謝謝你..它的工作很大 – Kim 2012-04-13 15:02:48