I have an STI model structure where super-class is User and sub-classes are Member and NonMember. I want to have only one Member and multiple NonMember for an email. For e.g. with email [email protected]
there can be only one Member object but at the same time we can have multiple NonMember with that email for different subdomains.
Please let me know how to take care of this as I am stuck on it and I have to tackle this problem very soon.
Here is STI relation alongwith email uniqueness validation. I hope it will help !
class User < ActiveRecord::Base
end
class Member < User
validates uniqueness_of :email
end
class NonMember < User
validates_uniqueness_of :email, :scope => :subdomain
end