This is fired off in a 'clone' action in a controller.
The meal has_many meal_foods. Each meal_foods belongs_to a meal. The meal that is being cloned has many meal_foods associated with it.
When I clone it, I do in fact see some foods in the controller before the new meal is saved, but the associations aren't saved. I see the meal itself has no id since it hasn't been saved yet, thus the meal_foods can't be associated to it.
With that said, must I clone the original meal, and then write my own code to save the meal_foods from the original meal to the new one, or is something that should be handled by this gem?
Hello!
Here's my code:
@original_meal = Meal.find(params[:id]) @meal = @original_meal.deep_clone include: :meal_foods
This is fired off in a 'clone' action in a controller.
The meal has_many meal_foods. Each meal_foods belongs_to a meal. The meal that is being cloned has many meal_foods associated with it.
When I clone it, I do in fact see some foods in the controller before the new meal is saved, but the associations aren't saved. I see the meal itself has no id since it hasn't been saved yet, thus the meal_foods can't be associated to it.
With that said, must I clone the original meal, and then write my own code to save the meal_foods from the original meal to the new one, or is something that should be handled by this gem?