I have two models involved: guides and steps. I expect to be able to create a guide and create steps associated with that guide from the Forest Admin web interface. I sent this issue to [email protected] but I'm posting it here in case someone from the community has had a similar issue and might have a solution.
I am able to create a guide but when I try to create a step associated with that guide no network request is made and an error is logged to the console. This error was not occurring the last time I tried it (September 19) and we've made no model/code changes in several months.
"use strict";
module.exports = function(sequelize, DataTypes) {
var guides = sequelize.define("guides", {
title: {
type: DataTypes.STRING,
allowNull: true
},
subtitle: {
type: DataTypes.STRING,
allowNull: true
},
image: {
type: DataTypes.STRING,
allowNull: true
},
image_thumbnail: {
type: DataTypes.STRING,
allowNull: true
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
product_identifier: {
type: DataTypes.STRING,
allowNull: true
},
archive: {
type: DataTypes.STRING,
allowNull: true
},
reduced_mobility: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
},
language: {
type: DataTypes.ENUM("fr", "en"),
defaultValue: "fr",
allowNull: false
},
credit_image: {
type: DataTypes.STRING,
allowNull: true
},
link: {
type: DataTypes.STRING,
allowNull: true
},
archive_size_string: {
type: DataTypes.STRING,
allowNull: true
},
archive_size_bytes: {
type: DataTypes.INTEGER,
allowNull: true
},
order: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 1
},
autoplay: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
onsite_limit: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
environment: {
type: DataTypes.ENUM("development", "staging", "production"),
defaultValue: "development",
allowNull: false
},
guide_type: {
type: DataTypes.ENUM("navigation", "audio", "parcour"),
defaultValue: "navigation",
allowNull: false
},
is_free: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
}
});
guides.associate = function(models) {
guides.hasMany(models.steps);
guides.belongsTo(models.locations, {
foreignKey: "start_location_id",
as: "start_location"
});
guides.belongsTo(models.locations, {
foreignKey: "end_location_id",
as: "end_location"
});
};
return guides;
};
'use strict';
module.exports = function(sequelize, DataTypes) {
var steps = sequelize.define('steps', {
order: {
type: DataTypes.INTEGER,
allowNull: true,
validate: {
min: 0,
},
},
playlist_title: {
type: DataTypes.STRING,
allowNull: true,
},
playlist_instruction: {
type: DataTypes.STRING,
allowNull: true,
},
title: {
type: DataTypes.STRING,
allowNull: false,
},
meta: {
type: DataTypes.STRING,
allowNull: true,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
image: {
type: DataTypes.STRING,
allowNull: true,
},
image_thumbnail: {
type: DataTypes.STRING,
allowNull: true,
},
audio: {
type: DataTypes.STRING,
allowNull: true,
},
guide_id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'guides',
key: 'id',
},
},
step_type: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'other',
},
autoplay_group: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'none',
},
ext_id: {
type: DataTypes.INTEGER,
allowNull: true,
},
ext_data: {
type: DataTypes.TEXT,
allowNull: true,
},
ext_updated_at: {
type: DataTypes.STRING,
allowNull: true,
},
});
steps.associate = function(models) {
steps.belongsTo(models.guides);
steps.belongsToMany(models.beacons, { through: 'step_beacon' });
}
return steps;
};
TypeError: Cannot read property 'get' of null
at client-5fdff9cef7c56β¦54b566218f6.js:1177
at o.forEach (vendor-039ff5e8d2118β¦4f25499893e.js:3532)
at o.saveNewRecord (client-5fdff9cef7c56β¦54b566218f6.js:1176)
at o.y (vendor-039ff5e8d2118β¦4f25499893e.js:3287)
at d (vendor-039ff5e8d2118β¦4f25499893e.js:3932)
at E.trigger (vendor-039ff5e8d2118β¦4f25499893e.js:4089)
at o.send (vendor-039ff5e8d2118β¦4f25499893e.js:3323)
at o.send (vendor-039ff5e8d2118β¦4f25499893e.js:3494)
at o.triggerAction (vendor-039ff5e8d2118β¦4f25499893e.js:3600)
at o.sendAction (vendor-039ff5e8d2118β¦4f25499893e.js:3759)