我不想说什么。
我愿获得所有<<>Carts, 其中有cart_stage.stage/strong>,等于35(这是一个单独的表格,一个汽车有多个阶段)。
弹片舱是像
id ----- cart_id ----- stage
1 ------- 123 ---------- 20
2 ------- 123 ---------- 35
3 ------- 102 ---------- 35
我现在试图这样做:
# Cart model
has_one :top_stage, :foreign_key => cart_id , :class_name => "CartStage", :order => stage
# Cart controller
@carts = Cart.find :all, :order => created_at DESC , :include => :top_stage, :conditions => ["top_stage.stage = ?", 35]
这使我:
SQLite3::SQLException: no such column: top_stage.stage: SELECT DISTINCT "carts".id FROM "carts" WHERE (top_stage.stage = 35) ORDER BY created_at DESC LIMIT 40 OFFSET 0
希望一切都有意义,任何帮助都将受到高度赞赏。
* A/63/150。