So guys i'm working on a tournament bracket based on the GOjs library, The bracket has score input. Once my user is done editing the bracket i save the bracket into a json variable :
function save() {
var tojs = myDiagram.model.toJSON();
var payload = JSON.parse(tojs);
stringify_tojs = JSON.stringify(payload);
myDiagram.isModified = false;
I use XMLHttpRequest to able to post the payload into my rails model that handles 'payload' :
var request = new XMLHttpRequest();
request.onload = callback;
request.open("post", "http://localhost:3000/malesingles");
request.setRequestHeader("Content-Type", "application/json");
request.send(payload);
I dont know where i went wrong but i'm certain it's around my controller params but i can't find my mistake already been a week, the controller looks something like this :
@tournoi = Tournoi.new(bracket_params)
if @tournoi.save
redirect_to root_url
flash[:success] = "Your tournament bracket has been validated!"
# redirect_to @tournoi
else
render 'new'
end
end i have included the bracket_params in private settings
def bracket_params
params.require(:tournoi).permit(:payload)
end
Tried different method to post the payload none really work, would appreciate some help to understand where i went wrong, i get a param is missing or empty :/.