I have a model Competitor like this
class Competitor < ActiveRecord::Base
belongs_to :admin_user
has_many :companies
attr_accessible :admin_user_id, :c1, :c2, :c3, :c4, :c5
validates :admin_user_id, :presence => true
validates_uniqueness_of :admin_user_id, :message => "This user has yet a competitors list"
end
C1, c2,.. are the id of companies. Selected from a drop down list. How can I validate the uniqueness of a row?
(i.e. is not possible to have two or more equals companies for an admin user BUT they can be empties).
You could write your own validation method that would enforce this.