I am implementing a Activity / update stream for a social networking site. I need to define relations at runtime based on the ‘activityType’ field value. For instance if its value is “photoalbum” it should relate to a photoalbum model or if its value is “Event” then it should relate to the event model.
But, I get an error that the property Activity.parentType is not defined. Any idea how to fix this. I know we can define relation separately for every model. But this looks more cleaner and reduces redundancy.
Thanks for the link. I am not defining foreign keys in my database, so its not an issue with MySQL. Rather it is giving error because its checking the relations before the values of the model are initialized (activityType not defined).