I have many users, and they has_many :social_media_accounts, however, I want to only allow a unique social_media_account.type per user,
e.g. User "Bob" can only have one social_media_account.type of "Twitter"
How do I do this?
class User < ApplicationRecord
has_many :social_media_accounts
end
class SocialMediaAccount < ApplicationRecord
belongs_to :user
enum type: [
twitter: 1,
facebook: 2,
linkedin: 3
]
end