2013-08-05 34 views
0

我有3個模型商店部分和價格,部分有shop_id和價格有section_id 我如何顯示商店視圖中的價格?
控制器/ shop_controller.rb操作數應包含1列紅寶石在軌道上

... 
def show  
    @metod_one = Magazine.find(params[:id]) 
    @method_two = Section.find(:all, :conditions => ['shop_id = ?', @method_one]) 
    @method_three = Price.find(:id, :conditions => ['section_id = ?', @method_two]) 
end 
... 

該方法不工作 Mysql的::錯誤:操作數應含有1個柱(一個或多個):SELECT * FROM prices WHERE(pricesid =「---: ID \ n」和(SECTION_ID = 5480,5482,5483,5485))

回答

1

請嘗試in操作:

@method_three = Price.find(:all, :conditions => ['section_id in (?)', @method_two]) 
+0

TNKS,但不適合我工作10找不到Price with ID = id AND(section_id in(4341,4342,4343)) – Andrew

+0

我改變了:id on:all和this work,thx – Andrew