Welcome Guest, Not a member yet? Register   Sign In
self-referencing relationship is not working using datamapper
#10

[eluser]WanWizard[/eluser]
Reciprocal means that when you save a relation, it will also be saved in the other direction. You use it when you have parent->child relations, where a child must always have a parent, AND the parent must have a relation with the child at the same time.

The problem here is that you have multiple relations between categories, and when you just use save(), Datamapper doesn't know which relationship you mean as you haven't told Datamapper which one to use. So it defaults to the relation with the same name as the class, which is your second one.

Either use $parent->save_relation($child), or $parent->save($child, 'relation'). See the manual, http://datamapper.wanwizard.eu/pages/save.html, under "saving an advanced relationship".


Messages In This Thread
self-referencing relationship is not working using datamapper - by El Forum - 04-10-2011, 11:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB