Skip to content

Instantly share code, notes, and snippets.

@danfinlay
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save danfinlay/10938369 to your computer and use it in GitHub Desktop.

Select an option

Save danfinlay/10938369 to your computer and use it in GitHub Desktop.
A tricky problem involved named through associations in Geddy's Model. This current arrangement throws the error `Error: The property "adminTeamTeamId" is not a valid property on the TeamAdmin model.`
var Team = function () {
this.hasMany('TeamUsers');
this.hasMany('Users', {through: 'TeamUsers'});
this.hasMany('TeamAdmins');
this.hasMany('Admins', {
through: 'TeamAdmins',
model: 'Users'
});
}
exports.Team = Team;
var TeamAdmin = function () {
this.belongsTo('AdminTeam',{model:'Team'});
this.belongsTo('User');
};
exports.TeamAdmin = TeamAdmin;
var TeamUser = function () {
this.belongsTo('Team');
this.belongsTo('User');
};
exports.TeamUser = TeamUser;
var User = function () {
this.hasMany('TeamUsers');
this.hasMany('Teams', {through: 'TeamUsers'});
this.hasMany('TeamAdmins');
this.hasMany('AdminTeams', {through: 'TeamAdmins', model:'Teams'});
}
exports.User = User;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment