Вот решение, возвращающее обещание в ванильном Javascript (без грязных обратных вызовов). По умолчанию он проверяет каждые 200 мс.
function waitFor(selector) {
return new Promise(function (res, rej) {
waitForElementToDisplay(selector, 200);
function waitForElementToDisplay(selector, time) {
if (document.querySelector(selector) != null) {
res(document.querySelector(selector));
}
else {
setTimeout(function () {
waitForElementToDisplay(selector, time);
}, time);
}
}
});
}
в вашем контроллере (новый) вы пропустили '@' и используете student_detail, поскольку ваша модель использует student_detail (помните, что has_one не has_many)
@participant= Participant.new
@student_detail= @participant.build_student_detail(participant: @participant)