I get this exception when creating a nested model:
ActiveRecord::AssociationTypeMismatch in RecipesController#update
Ingredient(#35624480) expected, got Ingredient(#34767560)
Models include recipe and ingredient. The recipe has_many and accepts_nested_attributes_for: ingredients that belong to the recipe.
I get this exception when _destroy (= 1) tries one of the pre-existing ingredients in the Ingredient sub-form for Editing / updating the recipe.
This makes little sense, mainly because the types of associations are as expected (with the exception of their own tolerance).
Even less important, it works great in a functional test .
In addition, it sometimes works if I re-post the form (via a browser update on Update). It will also work if I restart the development (development) web server.
Any ideas that might be causing this, or what should I look for?
source
share