Skip to content


has_one polymorphic is creating circular dependency with parent model #1075

lighthouse-import opened this Issue · 1 comment

1 participant


Imported from Lighthouse. Original ticket at:
Created by Gabriel Mazetto - 2011-05-02 04:49:47 UTC

Use this two models:

class Item < ActiveRecord::Base
belongs_to :itemable, :polymorphic => true

class Product < ActiveRecord::Base
has_one :item, :as => :itemable, :dependent => destroy
accepts_nested_attributes_for :item

now try to:

@product =[:product])

And you will get a error lacking the "item.itemable_id"

So, build_item is defining the correct itemable_type, but are not dealing with the id... I expect it to save "course" first, get it's id and them set it on itemable_id and then save "item".


Imported from Lighthouse.
Comment by Gabriel Mazetto - 2011-05-02 04:52:57 UTC

Also forget to mention that it's rails 3.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.