I have a simple database that has the following relation
Each Question has one Questiontype (3 different typs , such as Questiontype1 , Questiontype2 , Questiontype3 )
in Questiontype has question_id
- Question.rb (Model)
class Question < ActiveRecord::Base belongs_to :questiontype1 belongs_to :questiontype2 belongs_to :questiontype3 end
- Questiontype1.rb (Model)
class Questiontype1 < ActiveRecord::Base has_many :questions , :foreign_key => "question_id" end
- show.json.rabl (I used Rabl)
object @question attributes :id child :questiontype1 => :questiontype1 do attributes :id end
However, when I get child from Questiontype1 , result is null
Can I solve this problem?
Sorry for my English , Thank you.