Tried to find an answer with Google, but I must not be using the right search terms ;-(
I've got a simple one-to-many association:
Club hasMany Teams.
Team belongsTo Club
I want to remove a team from a club without deleting the club or the team.
I figured I just get the team and set it's clubid to 0 (I also tried '') and 'save' the team.
Team = model("Team").findOneByIdAndClubid(value="#params.key#,#params.clubid#");
team.clubid = 0;
if (Team.save()){
renderWith(status="success", message="The team was removed successfully.", redirect={back="true"});
} else {
renderWith(status="error", message="There was an error removing the teams.", redirect={back="true"});
}
Team.save() throws an error.
I bet I'm just missing something obvious, right?
Thanks in advance…martin