【发布时间】:2017-02-09 11:14:09
【问题描述】:
我有一个由has_many through 关联的课程Test, Question, Testquestion
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 时,我想传递order 的列Testquestion 的值。
def create
Test.create(test_params)
end
def test_params
params.require(:test).permit(:testname,question_attributes:[:questionname])
end
我应该如何传递order 列的值以便更新关联的模型(Testquestion)。
【问题讨论】:
标签: ruby-on-rails-4 activerecord nested-attributes has-many-through