0
我有一个类Test, Question, Testquestion
通过has_many through
传递参数中的has_many通过关联
class Test
has_many :testquestions
has_many :questions, through: :testquestions
end
class Question
has_many :testquestions
has_many :tests, through: :testquestions
end
class Testquestion
belongs_to :test
belongs_to :questions
end
相关在创建Test
我想传递的Testquestion
order
列的值。
def create
Test.create(test_params)
end
def test_params
params.require(:test).permit(:testname,question_attributes:[:questionname])
end
我应该如何通过order
列的值,使相关模型(Testquestion)得到更新。
它的工作就像一个魅力。非常感谢你 –