Closed stopachka closed 10 years ago
The problem was in the child models, with the validates for job_id
validates :job_id, presence: true
When I removed that validation, the form functioned correctly, and the job_id was added to the nested models.
My hunch is that maybe the validates occurs before rails creates a job_id, hence halting the whole proccess altogether.
This is the way accepts_nested_attributes_for
works in Rails. nested_form
gem only wraps this with form helpers and some javascript.
Maybe setting inverse_of
in your associations will help.
Hi guys, I'm working on implementing nested_forms. I think I'm getting close, but when I try run the create action, I get an error
It seems to me like the info for job_id(the parent of the has_many relationship) is not passing through the nested forms.
What do you guys think I'm doing off?
Here's the basic structure ->
When creating a new 'Job', a user will have the option to write in multiple bullet points about it, and multiple 'Roles'
Here's how the models are set up :
Job Model
Bullet Model
Role Model
Jobs Controller :
Jobs/New View
Logs
Here are some logs to make it a bit clearer:
1) When I submit the form, choosing only 1 bullet I get the following parameters in development:
On my Rails Server, this is what it's saying ->