I have a Resume Model that has_many :skills, and my skills model that belongs_to :resume.
I am nesting the skills form inside the resume form and it's creating the record and relationship perfectly. But when I try to destroy the resume, the associated Skill is not being destroyed along with it.
Here are my models:
# Resume.rb
class Resume < ActiveRecord::Base
has_many :skills
belongs_to :user
accepts_nested_attributes_for :skills, allow_destroy: true
end
# Skill.rb
class Skill < ActiveRecord::Base
belongs_to :resume
end
Here's the strong params in the resume_controller.rb
def resume_params
params.require(:resume).permit(:user_id, :title, :summary, :job_title, skills_attributes [:skill_name, :_destroy])
end
As far as I can tell I am passing the _destroy key properly. I noticed some people had _destroy checkboxes in the form. I want the Skills to be deleted when I Destroy the entire resume. Thanks!