我希望在一行中选择所有QuizVersion
模型信息和相关模型。Quiz
以下是我到目前为止所拥有的,它没有输出任何Quiz
信息,只是QuizVersion
信息:
控制器:
class QuizzesController < ApplicationController
def getquiz
@myquiz = QuizVersion.joins(:Quiz).find([14,16])
end
end
测验模型:
class Quiz < ActiveRecord::Base
set_table_name "quizzes"
set_primary_key "quiz_ID"
has_many :QuizVersions, :primary_key => "quiz_version_id", :foreign_key => "quiz_version_id"
end
测验版本型号:
class QuizVersion < ActiveRecord::Base
# attr_accessible :title, :body
set_primary_key "quiz_version_id"
belongs_to :Quiz, :primary_key => "quiz_id", :foreign_key => "quiz_id"
end
这是结果信息:
---
- !ruby/object:QuizVersion
attributes:
quiz_version_id: 14
quiz_id: 18
quiz_name: Super Hero Quiz
intro: Take this quiz to find out which super hero you are most like!
email: ''
activated: 0
ip_address: 127.0.0.1
public: 0
quiz_type: ''
created_time: 1347360590
- !ruby/object:QuizVersion
attributes:
quiz_version_id: 16
quiz_id: 18
quiz_name: Super Hero Quiz
intro: Take this quiz to find out which super hero you are most like!
email: ''
activated: 0
ip_address: 127.0.0.1
public: 0
quiz_type: ''
created_time: 1347706841