i have the following structure:
class FundFilter < ActiveRecord::Base
has_many :fund_filter_users, dependent: :destroy
has_many :users, through: :fund_filter_users
end
class FundFilterUser < ActiveRecord::Base
belongs_to :fund_filter
belongs_to :user
end
class User < ActiveRecord::Base
has_many :fund_filter_users, dependent: :destroy
has_many :fund_filters, through: :fund_filter_users
end
What i need is a validator on the :name of a fund_filter, which cannot repeat for a single user. Meaning for a single user_id in FundFilterUser, i need to check all fund_filter_ids where :name for that fund filter doesnt get repeated.
Ideas?