Hi, I'm using accepts_nested_attributes_for with the following models:
User model:
class User < ActiveRecord::Base
has_many :competences
has_many :skills, :through => :competences, :foreign_key => :skill_id
accepts_nested_attributes_for :skills
end
Skill model:
class Skill < ActiveRecord::Base
has_many :competences
has_many :users, :through => :competences, :foreign_key => :user_id
end
Competence model:
class Competence < ActiveRecord::Base
belongs_to :user
belongs_to :skill
end
The Skill table has a "name" attribute. How can I have accepts_nested_attributes_for not create a new skill record if a record with the same skill name already exists?