-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding nested forms with multiple models (many-to-many association) #461
Comments
The error in the logfile states that the |
Hey Nathan, As you can see in my post I actually did some debugging and know where is the problem. |
What do you mean, strong parameters have to stay as they are? You could just do something like:
|
For example, also check the demo project: https://github.com/nathanvda/cocoon_simple_form_demo/blob/master/app/controllers/projects_controller.rb |
I did as you said and got error https://github.com/MajQel/Elena
|
I am sorry I missed this but it seems so obvious: the Please checkout the example project in detail. |
Ah yes.... indeed that was the issue 🤦♂️ Also had switch And now everything is working. Thank you very much for your time Nathan 🥇 |
Hello,
First of all cocoon is one of my top gems (I'm using it in every single application).
Recently I am struggling for quite some time with nested forms for has_many through association.
What I need?
Create association for 2 attributes of 2 models
Model 1. RecipeIngredient attribute quantity
Model 2. Ingredient attribute name
Controller Recipe
List of models:
_form for recipe creation
Actual nesting:
Recipe controller line responsible for accepting params (there is rather no need to place here other methods)
Validation error (Ingredient name attribute seems to be not assiociated with recipe as it should be):
My research why this happens:
Problem is this line:
So my actual question.... is there workaround to this?
Ingredient name needs to be passed to Recipe params instead of RecipeIngredient params.
Both attributes needs to be created with proper association.
The text was updated successfully, but these errors were encountered: