I want to be able to enter entries in my database, where the manufacturer will be presented several times, but does not match the combination of the manufacturer and model. So “Sony (manufacturer), TV (model)” is okay “Sony (manufacturer), OtherTv (model)”, but the third entry “Sony (manufacturer), TV (model)” is not ok, because the combination of manufacturer and model not unique. I tried with validation :key => true, but it doesn't seem to work. And I can’t do something like validates_uniqueness_of :manufacturer AND :modelI think. So how do you do this?
class Tvs
include DataMapper::Resource
property :id, Serial
property :manufacturer, String, :key => true
property :model, String, :key => true
validates_uniqueness_of :
end
source
share