I have a standard many-to-many relationship between users and roles in my Rails app:
class User < ActiveRecord::Base has_many :user_roles has_many :ro
Perhaps it is possible to create the validation rule
validates_uniqueness_of :user_roles
then catch the validation exception and carry on gracefully. However, this feels really hacky and is very inelegant, if even possible.