我有了下面的關係式的簡單數據庫Rails的一個一對多關係,結果爲空
每個問題都有一個Questiontype(3不同typs,如Questiontype1,Questiontype2,Questiontype3)
在Questiontype已question_id
- Question.rb(型號)
類問題<的ActiveRecord ::基地 belongs_to的:questiontype1 belongs_to的:questiontype2 belongs_to的:questiontype3 端
- Questiontype1.rb(型號)
class Questiontype1 < ActiveRecord的::基地的has_many:疑問 :foreign_key => 「question_id」 結束
- show.json.rabl(I使用Rabl的)
對象@question屬性:id child:questiontype1 => :questiontype1 do attributes:id end
然而,當我從Questiontype1得到孩子時,結果爲空
我可以解決這個問題嗎?
對不起,我的英文,謝謝。
不要忘記接受答案:) – apneadiving 2012-02-11 13:51:12