I have two models, a profile model and a job model. A profile has_many jobs and a job belongs_to a profile. I am using the cacoon gem in order to create nested forms. In my application, someone creates a profile, and then they can add jobs. So, by the time they are making their first job, a profile is already created, a job is not, and the form data will go to the update action (since a profile already exists, even though no jobs do). The problem is, since there are no jobs yet, I am receiving the error:
param not found: profile
Here are the params I tried using:
def profile_params
params.require(:profile).permit(:title, :category, :description, :state, :zip_code, :rate, jobs_attributes: [:firm, :position, :category, :description, :begin, :end, :_destroy])
end
I then switched to the following code as recommended from another stack overflow post:
def profile_params
params.fetch(:profile, {}).permit(:title, :category, :description, :state, :zip_code, :rate, jobs_attributes: [:firm, :position, :category, :description, :begin, :end, :_destroy])
end
With the second profile_params (the one with fetch), the page will load with a successful flash message, but the job is not actually being created. I don't think the fetch is working. Any ideas on how to get this working? Thanks.