AssociationTypeMismatch with Expected Type on Nested Model Forms
Posted
by Craig Walker
on Stack Overflow
See other posts from Stack Overflow
or by Craig Walker
Published on 2010-05-24T19:51:41Z
Indexed on
2010/05/24
21:11 UTC
Read the original article
Hit count: 327
I'm getting this exception when doing a nested model form:
ActiveRecord::AssociationTypeMismatch in RecipesController#update
Ingredient(#35624480) expected, got Ingredient(#34767560)
The models involved are Recipe and Ingredient. Recipe has_many and accepts_nested_attributes_for :ingredients, which belongs_to :recipe.
I get this exception when attempting to _destroy (=1) one of the preexisting Ingredients on a nested Ingredient form for the Recipe Edit/Update.
This makes very little sense, mostly because the association types are as expected (by the exception's own admission).
What makes even less sense is that it works just fine in a functional test.
Any ideas what might be causing this, or what I should be looking for?
© Stack Overflow or respective owner