search for: favoriteteams

Displaying 1 result from an estimated 1 matches for "favoriteteams".

Did you mean: favorite_teams
2006 Jul 02
1
prevent duplicate inserts with has_many :through ??
Does anyone have an efficient/elegant way to prevent duplicate inserts when using a has_many :through relationship. So I have something like this: class User < ActiveRecord::Base has_many :favorite_teams has_many :teams, :through => :favorite_teams end class FavoriteTeams < ActiveRecord::Base belongs_to :user belongs_to :team end class Teams < ActiveRecord::Base has_many :favorite_teams has_many :users, :through => :favorite_teams end If one user creates a team like ''nationals'' it will create the record in the teams table and th...