0
私のモデルに参加追加:このコードはSaveFailureErrorを提起するのはなぜ?:1対多スルーモデルインスタンスに
変数@resultsはハッシュ(キーです@visit.test_visits.clear
@results.each do |test, result|
@visit.test_visits.new(:test => test, :result => result)
end
@visit.save
class Test
include DataMapper::Resource
property :id, Serial
property :name, String, :default => ''
has n, :test_visits
has n, :visits, :through => :test_visits
# ...
end
class Visit
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :test_visits
has n, :tests, :through => :test_visits
# ...
end
class TestVisit
include DataMapper::Resource
property :result, String
belongs_to :test, :key => true
belongs_to :visit, :key => true
end
を:テスト、値:文字列)