我有了下面的关系式的简单数据库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