I can't figure out why it's generating duplicate recruit_profiles_skills instead of updating.
class RecruitProfile < ActiveRecord::Base
has_many :skills, :through => :recruit_profiles_skills
has_many :recruit_profiles_skills, :dependent => :destroy
accepts_nested_attributes_for :recruit_profiles_skills, :allow_destroy => true
class Skill < ActiveRecord::Base
has_many :recruit_profiles, :through => :recruit_profiles_skills
has_many :recruit_profiles_skills, :dependent => :destroy
Params looks like
"recruit_profile"=>{
"recruit_profiles_skills_attributes"=>[{"skill_id"=>"1", "level"=>"15"}]
}
Then I do
def update
@recruit_profile.update_attributes(params[:recruit_profile])
But, this creates duplicate association records. Why does this not simply update!? I can prevent the duplicates using validations, but then it never updates since it just wants to create a new record, but the new record is invalid because it fails the validation.