ruby on rails - Building a record with polymorphic assocation with FactoryGirl -
i know why getting error when building record using factorygirl.
comment model belongs user , commentable through polymorphic association.
my factory looks this:
factorygirl.define factory :comment text "some text" user_id 1 association :commentable, factory: :feedback end end when i'm build comment record using factorygirl, get:
activemodel::missingattributeerror: can't write unknown attribute `commentable_type' i have no problem creating , manipulating comment object in console. can set , save commentable_type attribute freely. also, commentable_type exists in comments table.
any thoughts on why error occurs?
i ran migrations again using rake db:reset , error has disappeared. before that, have tried rollback related migration , migrate again, did not make change.
i still not know caused error, now, fixed.
Comments
Post a Comment