You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using polymorphic associations and passing the assoc_id to build/2 allows me to build records, but create fails as its trying to build with the abstract table name rather than the concrete one. The fun thing is, I can manually pipe whatever was built into a Repo.insert! and my insertion is successful.
# factory
def factory(:vendor_image) do
name = sequence(:filename, &"file-#{&1}.jpg")
build_assoc(%Vendor{}, :images, [
filename: name,
alt: "Caption text for #{name}",
medium: "priv/images/medium-#{name}",
original: "priv/images/original-#{name}"
])
end
# usage..
v = Factory.create(:vendor)
# fails, because its attempting to insert into the abstract table
i = Factory.create(:vendor_image, assoc_id: v.id)
# succeeds
i = Factory.build(:vendor_image, assoc_id: v.id) |> Repo.insert!
The text was updated successfully, but these errors were encountered:
I'll have to take a look at this next week. We may want to wait until Ecto 2.0 is finished because I think it will handle a lot of these edge cases automatically and it looks like it is coming along nicely. I'll post here with news.
@novaugust This should be fixed in master. ExMachina now supports Ecto 2.0.0 (which is still in beta) and it should fix the issue you are having. If it doesn't please reopen the issue :D
awesome, thanks for the ping. we've worked around it for now, so upgrading + reimplementing won't be at the top of our priorities for a bit, but i'll definitely hit you back when we do it
(cc @jthopple)
Using polymorphic associations and passing the
assoc_id
tobuild/2
allows me to build records, butcreate
fails as its trying to build with the abstract table name rather than the concrete one. The fun thing is, I can manually pipe whatever was built into aRepo.insert!
and my insertion is successful.The text was updated successfully, but these errors were encountered: