0

我有 3 个模型 Shop Section 和 Price,Section 有 shop_id,Price 有 section_id 如何在商店视图中显示价格?
控制器/shop_controller.rb

...
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::Error: Operand should contain 1 column(s): SELECT * FROM prices WHERE ( prices. id= '--- :id\n' AND (section_id = 5480,5482,5483,5485))

4

1 回答 1

2

请尝试in运营商:

@method_three = Price.find(:all, :conditions => ['section_id in (?)', @method_two])
于 2013-08-05T15:08:45.140 回答