我有2个模型,一个例子:
class Report ...
belongs_to :answer_sheet
end
class AnswerSheet ...
has_one :report
end
当我做一个:
@answersheet.report = Report.create(:data => 'bleah')
@answersheet.save
# and then create another report and assign it to the same @answersheet
# assuming at this stage @answersheet is already reloaded
@answersheet.report = Report.create(:data => 'new data')
@answersheet.save
# (irb) @answersheet.report returns the first report with the data 'bleah' and not
# the one with the new data.
这应该是正确的行为吗?
如果我想将关联更新到以后的报告,我应该怎么做?