Мои модели:
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
Почему этот код вызывает ошибку SaveFailureError?:
@visit.test_visits.clear
@results.each do |test, result|
@visit.test_visits.new(:test => test, :result => result)
end
@visit.save
где переменная @results - это Hash (ключи: Test, значения: String)