Closed louarnos closed 8 years ago
Maybe @RDegnen can help since he worked with you on it. Did you add a dependent destroy?
No we didnt. I dont really wanna solve this until my other issue is solved because they seem dependent on eachother
@louarnos The problem is that there isn't a dependent destroy. You're trying to delete a Meal, but that Meal is being referenced by a MealItem. Deleting the Meal would make that MealItem's foreign key point to a non-existent meal, violating the not-null constraint. ActiveRecord won't let you do that.
You need to either (a) set up dependent_destroy
on your Meals (and, presumably, Foods), or (b) manually delete any related MealItems any time you delete a Meal or Food.
@MattB-GA-Boston are you addressing this along with #292 as well?
@louarnos how is this going?
@J-Weeks I'm working on it... I put a dependent destroy in my meals serializer and its still not working. I'm not convinced my serializers are set-up totally correctly.
the depended destroy would go in your model, not your serializer
Needed to put a dependent destroy in my model, not my serializer...
I think this stems back to the solution that @RDegnen and I came up with for my Post issue. When I delete my server gives me:
If I'm understanding it correctly, because a reference to the meal that is being deleted still exists on the meal_items table, it fails.