If anybody is having the same problem here is how I solved it
validate :uniqueness_within_category
def uniqueness_within_category
first_category_type = (Tag.find_by(category: self.category).nil?)? 'none' : Tag.find_by(category: self.category)._type
if first_category_type == 'none'
#It doesnt exist then should be allowed
return
end
#If it exists within another class type then shouldnt be allowed
if self._type != first_category_type
errors.add(:category, 'Must be unique within tag type')
end
end
Testing started at 6:22 PM ...
1 examples, 0 failures, 1 passed