I have a 2 models Game
& Theme
and they have a has_and_belongs_to_many association. I have tried many solutions to prevent duplicate records in the games_themes
table, but no solutions work. The problem is, games_themes
is a table, but it is not a model, so I can't figure out a way to run validations on it effectively.
Heres a solution I tried
class Theme < ActiveRecord::Base
has_and_belongs_to_many :games, :uniq => true
end
class Game < ActiveRecord::Base
has_and_belongs_to_many :themes, :uniq => true
end